Boost logo

Boost-Commit :

From: igaztanaga_at_[hidden]
Date: 2007-08-25 15:17:24


Author: igaztanaga
Date: 2007-08-25 15:17:24 EDT (Sat, 25 Aug 2007)
New Revision: 38953
URL: http://svn.boost.org/trac/boost/changeset/38953

Log:
#1211: Interprocess tests hang when run in parallel
#1080 boost::interprocess win32 global file mapping issue
Added:
   trunk/boost/interprocess/smart_ptr/deleter.hpp (contents, props changed)
Removed:
   trunk/boost/interprocess/smart_ptr/detail/sp_counted_base_pt.hpp
   trunk/boost/interprocess/smart_ptr/detail/sp_counted_base_w32.hpp

Added: trunk/boost/interprocess/smart_ptr/deleter.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/interprocess/smart_ptr/deleter.hpp 2007-08-25 15:17:24 EDT (Sat, 25 Aug 2007)
@@ -0,0 +1,61 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2007.
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/interprocess for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTERPROCESS_DELETER_HPP
+#define BOOST_INTERPROCESS_DELETER_HPP
+
+#if (defined _MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/interprocess/detail/config_begin.hpp>
+#include <boost/interprocess/interprocess_fwd.hpp>
+#include <boost/interprocess/detail/utilities.hpp>
+
+//!\file
+//!Describes the functor to delete objects from the segment.
+
+namespace boost {
+namespace interprocess {
+
+//!A deleter that uses the segment manager's destroy_ptr
+//!function to destroy the passed pointer resource.
+//!
+//!This deleter is used
+template<class T, class SegmentManager>
+class deleter
+{
+ public:
+ typedef typename detail::pointer_to_other
+ <typename SegmentManager::void_pointer, T>::type pointer;
+
+ private:
+ typedef typename detail::pointer_to_other
+ <pointer, SegmentManager>::type segment_manager_pointer;
+
+ segment_manager_pointer mp_mngr;
+
+ public:
+ deleter(segment_manager_pointer pmngr)
+ : mp_mngr(pmngr)
+ {}
+
+ void operator()(const pointer &p)
+ { mp_mngr->destroy_ptr(detail::get_pointer(p)); }
+};
+
+} //namespace interprocess {
+} //namespace boost {
+
+#include <boost/interprocess/detail/config_end.hpp>
+
+#endif //#ifndef BOOST_INTERPROCESS_DELETER_HPP

Deleted: trunk/boost/interprocess/smart_ptr/detail/sp_counted_base_pt.hpp
==============================================================================
--- trunk/boost/interprocess/smart_ptr/detail/sp_counted_base_pt.hpp 2007-08-25 15:17:24 EDT (Sat, 25 Aug 2007)
+++ (empty file)
@@ -1,135 +0,0 @@
-#ifndef BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_PT_HPP_INCLUDED
-#define BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_PT_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// This file is the adaptation for shared memory memory mapped
-// files of boost/detail/sp_counted_base_pt.hpp
-//
-//
-// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
-// Copyright 2004-2005 Peter Dimov
-// Copyright 2006 Ion Gaztañaga
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/interprocess/detail/config_begin.hpp>
-#include <boost/interprocess/detail/workaround.hpp>
-
-#include <typeinfo>
-#include <boost/interprocess/sync/posix/pthread_helpers.hpp>
-
-namespace boost{
-
-namespace interprocess{
-
-namespace detail{
-
-class sp_counted_base
-{
- private:
-
- sp_counted_base( sp_counted_base const & );
- sp_counted_base & operator= ( sp_counted_base const & );
-
- long use_count_; // #shared
- long weak_count_; // #weak + (#shared != 0)
-
- mutable pthread_mutex_t m_mut;
-
- public:
-
- sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
- {
- detail::mutexattr_wrapper mut_attr;
- detail::mutex_initializer mut(m_mut, mut_attr);
- mut.release();
- }
-
- ~sp_counted_base() // nothrow
- {
- int res = pthread_mutex_destroy(&m_mut);
- assert(res == 0);(void)res;
- }
-
- // dispose() is called when use_count_ drops to zero, to release
- // the resources managed by *this.
-/*
- virtual void dispose() = 0; // nothrow
-
- // destroy() is called when weak_count_ drops to zero.
-
- virtual void destroy() // nothrow
- {
- delete this;
- }
-
- virtual void * get_deleter( std::type_info const & ti ) = 0;
-*/
- void add_ref_copy()
- {
- pthread_mutex_lock( &m_mut );
- ++use_count_;
- pthread_mutex_unlock( &m_mut );
- }
-
- bool add_ref_lock() // true on success
- {
- pthread_mutex_lock( &m_mut );
- bool r = use_count_ == 0? false: ( ++use_count_, true );
- pthread_mutex_unlock( &m_mut );
- return r;
- }
-
- bool ref_release() // nothrow
- {
- pthread_mutex_lock( &m_mut );
- long new_use_count = --use_count_;
- pthread_mutex_unlock( &m_mut );
-
- return new_use_count == 0;
- }
-
- void weak_add_ref() // nothrow
- {
- pthread_mutex_lock( &m_mut );
- ++weak_count_;
- pthread_mutex_unlock( &m_mut );
- }
-
- bool weak_release() // nothrow
- {
- pthread_mutex_lock( &m_mut );
- long new_weak_count = --weak_count_;
- pthread_mutex_unlock( &m_mut );
-
- return new_weak_count == 0;
- }
-
- long use_count() const // nothrow
- {
- pthread_mutex_lock( &m_mut );
- long r = use_count_;
- pthread_mutex_unlock( &m_mut );
-
- return r;
- }
-};
-
-} // namespace detail
-
-} // namespace interprocess
-
-} // namespace boost
-
-#include <boost/interprocess/detail/config_end.hpp>
-
-#endif // #ifndef BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_PT_HPP_INCLUDED

Deleted: trunk/boost/interprocess/smart_ptr/detail/sp_counted_base_w32.hpp
==============================================================================
--- trunk/boost/interprocess/smart_ptr/detail/sp_counted_base_w32.hpp 2007-08-25 15:17:24 EDT (Sat, 25 Aug 2007)
+++ (empty file)
@@ -1,119 +0,0 @@
-#ifndef BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_W32_HPP_INCLUDED
-#define BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_W32_HPP_INCLUDED
-
-// MS compatible compilers support #pragma once
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-//
-// This file is the adaptation for shared memory memory mapped
-// files of boost/detail/sp_counted_base_w32.hpp
-//
-//
-// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
-// Copyright 2004-2005 Peter Dimov
-// Copyright 2006 Ion Gaztañaga
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//
-//
-// Lock-free algorithm by Alexander Terekhov
-//
-// Thanks to Ben Hitchings for the #weak + (#shared != 0)
-// formulation
-//
-
-#include <boost/interprocess/detail/config_begin.hpp>
-#include <boost/interprocess/detail/workaround.hpp>
-
-#include <boost/interprocess/detail/win32_api.hpp>
-#include <typeinfo>
-
-namespace boost {
-
-namespace interprocess {
-
-namespace detail {
-
-class sp_counted_base
-{
-private:
-
- sp_counted_base( sp_counted_base const & );
- sp_counted_base & operator= ( sp_counted_base const & );
-
- long use_count_; // #shared
- long weak_count_; // #weak + (#shared != 0)
-
-public:
-
- sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
- {}
-
- ~sp_counted_base() // nothrow
- {}
-/*
- // dispose() is called when use_count_ drops to zero, to release
- // the resources managed by *this.
-
- virtual void dispose() = 0; // nothrow
-
- // destroy() is called when weak_count_ drops to zero.
-
- virtual void destroy() // nothrow
- {
- delete this;
- }
-
- virtual void * get_deleter( std::type_info const & ti ) = 0;
-*/
- void add_ref_copy()
- {
- winapi::interlocked_increment( &use_count_ );
- }
-
- bool add_ref_lock() // true on success
- {
- for( ;; )
- {
- long tmp = static_cast< long const volatile& >( use_count_ );
- if( tmp == 0 ) return false;
- if( winapi::interlocked_compare_exchange( &use_count_, tmp + 1, tmp ) == tmp ) return true;
- }
- }
-
- bool ref_release() // nothrow
- { return winapi::interlocked_decrement( &use_count_ ) == 0; }
-
-/*
- void release() // nothrow
- {
- if(ref_release()){
- //dispose();
- weak_release();
- }
- }
-*/
- void weak_add_ref() // nothrow
- { winapi::interlocked_increment( &weak_count_ ); }
-
- bool weak_release() // nothrow
- { return winapi::interlocked_decrement( &weak_count_ ) == 0; }
-
- long use_count() const // nothrow
- { return static_cast<long const volatile &>( use_count_ ); }
-};
-
-} // namespace detail
-
-} // namespace interprocess
-
-} // namespace boost
-
-#include <boost/interprocess/detail/config_end.hpp>
-
-#endif // #ifndef BOOST_INTERPROCESS_DETAIL_SP_COUNTED_BASE_W32_HPP_INCLUDED


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk