diff --git a/doc/interprocess.qbk b/doc/interprocess.qbk index ea25a1e..9af6bfb 100644 --- a/doc/interprocess.qbk +++ b/doc/interprocess.qbk @@ -6762,6 +6762,13 @@ thank them: [section:release_notes Release Notes] +[section:release_notes_boost_1_67_00 Boost 1.67 Release] +* Fixed bugs: + * [@https://github.com/boostorg/interprocess/pull/45 GitHub Pull #45 (['"Make intrusive_ptr move constructible/assignable"])]. + * [@https://github.com/boostorg/interprocess/pull/48 GitHub Pull #48 (['"Win32: Fix read of reg_expand_sz type"])]. + +[endsect] + [section:release_notes_boost_1_66_00 Boost 1.66 Release] * Fixed bugs: * [@https://github.com/boostorg/interprocess/pull/41 GitHub Pull #41 (['"Data race in boost::interprocess::rbtree_best_fit"])]. @@ -6784,7 +6791,7 @@ thank them: * [@https://github.com/boostorg/interprocess/pull/35 GitHub Pull #35 (['"Fixed options for cross-compilation"])]. * New experimental option `BOOST_INTERPROCESS_BOOTSTAMP_IS_SESSION_MANAGER_BASED` from Windows systems. - This option derives the unique booststamp used to name the folder where shared memory is placed from registry values associated + This option derives the unique bootstamp used to name the folder where shared memory is placed from registry values associated with the session manager. This option only works on Vista and later systems and might be more stable than the default version. [endsect] diff --git a/include/boost/interprocess/allocators/adaptive_pool.hpp b/include/boost/interprocess/allocators/adaptive_pool.hpp index 3c0d50f..801a436 100644 --- a/include/boost/interprocess/allocators/adaptive_pool.hpp +++ b/include/boost/interprocess/allocators/adaptive_pool.hpp @@ -102,7 +102,7 @@ class adaptive_pool_base typedef typename segment_manager::difference_type difference_type; typedef boost::interprocess::version_type version; - typedef boost::container::container_detail::transform_multiallocation_chain + typedef boost::container::dtl::transform_multiallocation_chain multiallocation_chain; //!Obtains adaptive_pool_base from diff --git a/include/boost/interprocess/allocators/allocator.hpp b/include/boost/interprocess/allocators/allocator.hpp index 759e3d2..9a5bf32 100644 --- a/include/boost/interprocess/allocators/allocator.hpp +++ b/include/boost/interprocess/allocators/allocator.hpp @@ -109,7 +109,7 @@ class allocator #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) //Experimental. Don't use. - typedef boost::container::container_detail::transform_multiallocation_chain + typedef boost::container::dtl::transform_multiallocation_chain multiallocation_chain; #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED diff --git a/include/boost/interprocess/allocators/detail/adaptive_node_pool.hpp b/include/boost/interprocess/allocators/detail/adaptive_node_pool.hpp index 2996bc8..d2b0b36 100644 --- a/include/boost/interprocess/allocators/detail/adaptive_node_pool.hpp +++ b/include/boost/interprocess/allocators/detail/adaptive_node_pool.hpp @@ -48,13 +48,13 @@ template< class SegmentManager , unsigned char OverheadPercent > class private_adaptive_node_pool - : public boost::container::container_detail::private_adaptive_node_pool_impl + : public boost::container::dtl::private_adaptive_node_pool_impl < typename SegmentManager::segment_manager_base_type , ::boost::container::adaptive_pool_flag::size_ordered | ::boost::container::adaptive_pool_flag::address_ordered > { - typedef boost::container::container_detail::private_adaptive_node_pool_impl + typedef boost::container::dtl::private_adaptive_node_pool_impl < typename SegmentManager::segment_manager_base_type , ::boost::container::adaptive_pool_flag::size_ordered | ::boost::container::adaptive_pool_flag::address_ordered diff --git a/include/boost/interprocess/allocators/detail/allocator_common.hpp b/include/boost/interprocess/allocators/detail/allocator_common.hpp index f613ffd..7939404 100644 --- a/include/boost/interprocess/allocators/detail/allocator_common.hpp +++ b/include/boost/interprocess/allocators/detail/allocator_common.hpp @@ -328,7 +328,7 @@ class array_allocation_impl ::type const_reference; typedef typename SegmentManager::size_type size_type; typedef typename SegmentManager::difference_type difference_type; - typedef boost::container::container_detail::transform_multiallocation_chain + typedef boost::container::dtl::transform_multiallocation_chain multiallocation_chain; @@ -442,7 +442,7 @@ class node_pool_allocation_impl ::type const_reference; typedef typename SegmentManager::size_type size_type; typedef typename SegmentManager::difference_type difference_type; - typedef boost::container::container_detail::transform_multiallocation_chain + typedef boost::container::dtl::transform_multiallocation_chain multiallocation_chain; diff --git a/include/boost/interprocess/allocators/detail/node_pool.hpp b/include/boost/interprocess/allocators/detail/node_pool.hpp index 9b2041f..552410a 100644 --- a/include/boost/interprocess/allocators/detail/node_pool.hpp +++ b/include/boost/interprocess/allocators/detail/node_pool.hpp @@ -45,10 +45,10 @@ namespace ipcdetail { template< class SegmentManager, std::size_t NodeSize, std::size_t NodesPerBlock > class private_node_pool //Inherit from the implementation to avoid template bloat - : public boost::container::container_detail:: + : public boost::container::dtl:: private_node_pool_impl { - typedef boost::container::container_detail::private_node_pool_impl + typedef boost::container::dtl::private_node_pool_impl base_t; //Non-copyable private_node_pool(); diff --git a/include/boost/interprocess/allocators/node_allocator.hpp b/include/boost/interprocess/allocators/node_allocator.hpp index 8bd6dfe..aa9931a 100644 --- a/include/boost/interprocess/allocators/node_allocator.hpp +++ b/include/boost/interprocess/allocators/node_allocator.hpp @@ -99,7 +99,7 @@ class node_allocator_base typedef typename segment_manager::difference_type difference_type; typedef boost::interprocess::version_type version; - typedef boost::container::container_detail::transform_multiallocation_chain + typedef boost::container::dtl::transform_multiallocation_chain multiallocation_chain; //!Obtains node_allocator_base from diff --git a/include/boost/interprocess/allocators/private_adaptive_pool.hpp b/include/boost/interprocess/allocators/private_adaptive_pool.hpp index 8929929..3491c16 100644 --- a/include/boost/interprocess/allocators/private_adaptive_pool.hpp +++ b/include/boost/interprocess/allocators/private_adaptive_pool.hpp @@ -100,7 +100,7 @@ class private_adaptive_pool_base typedef typename segment_manager::size_type difference_type; typedef boost::interprocess::version_type version; - typedef boost::container::container_detail::transform_multiallocation_chain + typedef boost::container::dtl::transform_multiallocation_chain multiallocation_chain; //!Obtains node_allocator from other node_allocator diff --git a/include/boost/interprocess/allocators/private_node_allocator.hpp b/include/boost/interprocess/allocators/private_node_allocator.hpp index 24fb84c..413e39c 100644 --- a/include/boost/interprocess/allocators/private_node_allocator.hpp +++ b/include/boost/interprocess/allocators/private_node_allocator.hpp @@ -95,7 +95,7 @@ class private_node_allocator_base typedef typename segment_manager::difference_type difference_type; typedef boost::interprocess::version_type version; - typedef boost::container::container_detail::transform_multiallocation_chain + typedef boost::container::dtl::transform_multiallocation_chain multiallocation_chain; //!Obtains node_allocator from other node_allocator diff --git a/include/boost/interprocess/containers/pair.hpp b/include/boost/interprocess/containers/pair.hpp index a6e11f4..ccd3c23 100644 --- a/include/boost/interprocess/containers/pair.hpp +++ b/include/boost/interprocess/containers/pair.hpp @@ -26,7 +26,7 @@ namespace boost { namespace interprocess { -using boost::container::container_detail::pair; +using boost::container::dtl::pair; } //namespace interprocess { } //namespace boost { diff --git a/include/boost/interprocess/containers/version_type.hpp b/include/boost/interprocess/containers/version_type.hpp index 22b5eef..6885072 100644 --- a/include/boost/interprocess/containers/version_type.hpp +++ b/include/boost/interprocess/containers/version_type.hpp @@ -25,8 +25,8 @@ namespace boost { namespace interprocess { -using boost::container::container_detail::version_type; -using boost::container::container_detail::version; +using boost::container::dtl::version_type; +using boost::container::dtl::version; } //namespace interprocess { } //namespace boost { diff --git a/include/boost/interprocess/detail/atomic.hpp b/include/boost/interprocess/detail/atomic.hpp index e32f056..041076c 100644 --- a/include/boost/interprocess/detail/atomic.hpp +++ b/include/boost/interprocess/detail/atomic.hpp @@ -567,6 +567,60 @@ inline boost::uint32_t atomic_cas32 inline void atomic_write32(volatile boost::uint32_t *mem, boost::uint32_t val) { __sync_synchronize(); *mem = val; } +} //namespace ipcdetail{ +} //namespace interprocess{ +} //namespace boost{ +#elif defined(__VXWORKS__) + +#include +// VxWorks atomic32_t is not volatile, for some unknown reason +#define vx_atomic_cast(_i) (reinterpret_cast< ::atomic32_t *>( const_cast(_i))) + +namespace boost { +namespace interprocess { +namespace ipcdetail{ + +//! Atomically add 'val' to an boost::uint32_t +//! "mem": pointer to the object +//! "val": amount to add +//! Returns the old value pointed to by mem +inline boost::uint32_t atomic_add32 + (volatile boost::uint32_t *mem, boost::uint32_t val) +{ return ::vxAtomic32Add( vx_atomic_cast(mem), val); } + +//! Atomically increment an apr_uint32_t by 1 +//! "mem": pointer to the object +//! Returns the old value pointed to by mem +inline boost::uint32_t atomic_inc32(volatile boost::uint32_t *mem) +{ return ::vxAtomic32Inc( vx_atomic_cast(mem) ); } + +//! Atomically decrement an boost::uint32_t by 1 +//! "mem": pointer to the atomic value +//! Returns the old value pointed to by mem +inline boost::uint32_t atomic_dec32(volatile boost::uint32_t *mem) +{ return ::vxAtomic32Dec( vx_atomic_cast(mem) ); } + +//! Atomically read an boost::uint32_t from memory +inline boost::uint32_t atomic_read32(volatile boost::uint32_t *mem) +{ return ::vxAtomic32Get( vx_atomic_cast(mem) ); } + +//! Compare an boost::uint32_t's value with "cmp". +//! If they are the same swap the value with "with" +//! "mem": pointer to the value +//! "with" what to swap it with +//! "cmp": the value to compare it to +//! Returns the old value of *mem +inline boost::uint32_t atomic_cas32 + (volatile boost::uint32_t *mem, boost::uint32_t with, boost::uint32_t cmp) +{ return ::vxAtomic32Cas( vx_atomic_cast(mem), cmp, with); } + +//! Atomically set an boost::uint32_t in memory +//! "mem": pointer to the object +//! "param": val value that the object will assume +inline void atomic_write32(volatile boost::uint32_t *mem, boost::uint32_t val) +{ ::vxAtomic32Set( vx_atomic_cast(mem), val); } + + } //namespace ipcdetail{ } //namespace interprocess{ } //namespace boost{ diff --git a/include/boost/interprocess/detail/in_place_interface.hpp b/include/boost/interprocess/detail/in_place_interface.hpp index 013691a..367f9dc 100644 --- a/include/boost/interprocess/detail/in_place_interface.hpp +++ b/include/boost/interprocess/detail/in_place_interface.hpp @@ -51,7 +51,7 @@ template struct placement_destroy : public in_place_interface { placement_destroy() - : in_place_interface(::boost::container::container_detail::alignment_of::value, sizeof(T), typeid(T).name()) + : in_place_interface(::boost::container::dtl::alignment_of::value, sizeof(T), typeid(T).name()) {} virtual void destroy_n(void *mem, std::size_t num, std::size_t &destroyed) diff --git a/include/boost/interprocess/detail/intermodule_singleton_common.hpp b/include/boost/interprocess/detail/intermodule_singleton_common.hpp index c890c32..392db1f 100644 --- a/include/boost/interprocess/detail/intermodule_singleton_common.hpp +++ b/include/boost/interprocess/detail/intermodule_singleton_common.hpp @@ -290,7 +290,7 @@ class intermodule_singleton_common static union mem_holder_t { unsigned char map_mem [sizeof(ThreadSafeGlobalMap)]; - ::boost::container::container_detail::max_align_t aligner; + ::boost::container::dtl::max_align_t aligner; } mem_holder; }; diff --git a/include/boost/interprocess/detail/managed_open_or_create_impl.hpp b/include/boost/interprocess/detail/managed_open_or_create_impl.hpp index 9351f39..b47c310 100644 --- a/include/boost/interprocess/detail/managed_open_or_create_impl.hpp +++ b/include/boost/interprocess/detail/managed_open_or_create_impl.hpp @@ -115,8 +115,8 @@ class managed_open_or_create_impl ct_rounded_size < sizeof(boost::uint32_t) , MemAlignment ? (MemAlignment) : - (::boost::container::container_detail::alignment_of - < ::boost::container::container_detail::max_align_t >::value) + (::boost::container::dtl::alignment_of + < ::boost::container::dtl::max_align_t >::value) >::value; managed_open_or_create_impl() diff --git a/include/boost/interprocess/detail/named_proxy.hpp b/include/boost/interprocess/detail/named_proxy.hpp index 4bec375..f3eb61d 100644 --- a/include/boost/interprocess/detail/named_proxy.hpp +++ b/include/boost/interprocess/detail/named_proxy.hpp @@ -274,7 +274,7 @@ class named_proxy T *operator()( BOOST_MOVE_UREF##N ) const\ {\ typedef typename if_c \ + , CtorIt##N \ , CtorArg##N \ >::type ctor_obj_t;\ ctor_obj_t ctor_obj = ctor_obj_t( BOOST_MOVE_FWD##N );\ diff --git a/include/boost/interprocess/detail/os_thread_functions.hpp b/include/boost/interprocess/detail/os_thread_functions.hpp index 8a0a47c..1c48ecf 100644 --- a/include/boost/interprocess/detail/os_thread_functions.hpp +++ b/include/boost/interprocess/detail/os_thread_functions.hpp @@ -52,6 +52,9 @@ # include # include # endif +#if defined(__VXWORKS__) +#include +#endif //According to the article "C/C++ tip: How to measure elapsed real time for benchmarking" //Check MacOs first as macOS 10.12 SDK defines both CLOCK_MONOTONIC and //CLOCK_MONOTONIC_RAW and no clock_gettime. @@ -480,6 +483,18 @@ inline unsigned int get_num_cores() else{ return static_cast(num_cores); } + #elif defined(__VXWORKS__) + cpuset_t set = ::vxCpuEnabledGet(); + #ifdef __DCC__ + int i; + for( i = 0; set; ++i) + { + set &= set -1; + } + return(i); + #else + return (__builtin_popcount(set) ); + #endif #endif } diff --git a/include/boost/interprocess/detail/segment_manager_helper.hpp b/include/boost/interprocess/detail/segment_manager_helper.hpp index cfa4bd2..96ccf22 100644 --- a/include/boost/interprocess/detail/segment_manager_helper.hpp +++ b/include/boost/interprocess/detail/segment_manager_helper.hpp @@ -117,7 +117,7 @@ struct block_header { return get_rounded_size ( size_type(sizeof(Header)) - , size_type(::boost::container::container_detail::alignment_of >::value)) + , size_type(::boost::container::dtl::alignment_of >::value)) + total_size(); } @@ -169,7 +169,7 @@ struct block_header template static block_header *block_header_from_value(T *value) - { return block_header_from_value(value, sizeof(T), ::boost::container::container_detail::alignment_of::value); } + { return block_header_from_value(value, sizeof(T), ::boost::container::dtl::alignment_of::value); } static block_header *block_header_from_value(const void *value, std::size_t sz, std::size_t algn) { @@ -190,7 +190,7 @@ struct block_header block_header * hdr = reinterpret_cast*>(reinterpret_cast(header) + get_rounded_size( size_type(sizeof(Header)) - , size_type(::boost::container::container_detail::alignment_of >::value))); + , size_type(::boost::container::dtl::alignment_of >::value))); //Some sanity checks return hdr; } @@ -201,7 +201,7 @@ struct block_header Header * hdr = reinterpret_cast(reinterpret_cast(bheader) - get_rounded_size( size_type(sizeof(Header)) - , size_type(::boost::container::container_detail::alignment_of >::value))); + , size_type(::boost::container::dtl::alignment_of >::value))); //Some sanity checks return hdr; } @@ -275,7 +275,7 @@ struct intrusive_value_type_impl intrusive_value_type_impl(){} - enum { BlockHdrAlignment = ::boost::container::container_detail::alignment_of >::value }; + enum { BlockHdrAlignment = ::boost::container::dtl::alignment_of >::value }; block_header *get_block_header() const { diff --git a/include/boost/interprocess/detail/transform_iterator.hpp b/include/boost/interprocess/detail/transform_iterator.hpp index 1c4dcd3..d409b52 100644 --- a/include/boost/interprocess/detail/transform_iterator.hpp +++ b/include/boost/interprocess/detail/transform_iterator.hpp @@ -27,170 +27,14 @@ // interprocess #include -// interprocess/detail -#include -// move/detail -#include +// container/detail +#include namespace boost { namespace interprocess { -template -struct operator_arrow_proxy -{ - operator_arrow_proxy(const PseudoReference &px) - : m_value(px) - {} - - PseudoReference* operator->() const { return &m_value; } - // This function is needed for MWCW and BCC, which won't call operator-> - // again automatically per 13.3.1.2 para 8 -// operator T*() const { return &m_value; } - mutable PseudoReference m_value; -}; - -template -struct operator_arrow_proxy -{ - operator_arrow_proxy(T &px) - : m_value(px) - {} - - T* operator->() const { return const_cast(&m_value); } - // This function is needed for MWCW and BCC, which won't call operator-> - // again automatically per 13.3.1.2 para 8 -// operator T*() const { return &m_value; } - T &m_value; -}; - -template -class transform_iterator - : public UnaryFunction -{ - public: - typedef typename ::boost::container::iterator_traits::iterator_category iterator_category; - typedef typename ipcdetail::remove_reference::type value_type; - typedef typename ::boost::container::iterator_traits::difference_type difference_type; - typedef operator_arrow_proxy pointer; - typedef typename UnaryFunction::result_type reference; - - explicit transform_iterator(const Iterator &it, const UnaryFunction &f = UnaryFunction()) - : UnaryFunction(f), m_it(it) - {} - - explicit transform_iterator() - : UnaryFunction(), m_it() - {} - - //Constructors - transform_iterator& operator++() - { increment(); return *this; } - - transform_iterator operator++(int) - { - transform_iterator result (*this); - increment(); - return result; - } - - transform_iterator& operator--() - { decrement(); return *this; } - - transform_iterator operator--(int) - { - transform_iterator result (*this); - decrement(); - return result; - } - - friend bool operator== (const transform_iterator& i, const transform_iterator& i2) - { return i.equal(i2); } - - friend bool operator!= (const transform_iterator& i, const transform_iterator& i2) - { return !(i == i2); } - - friend bool operator< (const transform_iterator& i, const transform_iterator& i2) - { return i < i2; } - - friend bool operator> (const transform_iterator& i, const transform_iterator& i2) - { return i2 < i; } - - friend bool operator<= (const transform_iterator& i, const transform_iterator& i2) - { return !(i > i2); } - - friend bool operator>= (const transform_iterator& i, const transform_iterator& i2) - { return !(i < i2); } - - friend difference_type operator- (const transform_iterator& i, const transform_iterator& i2) - { return i2.distance_to(i); } - - //Arithmetic - transform_iterator& operator+=(difference_type off) - { this->advance(off); return *this; } - - transform_iterator operator+(difference_type off) const - { - transform_iterator other(*this); - other.advance(off); - return other; - } - - friend transform_iterator operator+(difference_type off, const transform_iterator& right) - { return right + off; } - - transform_iterator& operator-=(difference_type off) - { this->advance(-off); return *this; } - - transform_iterator operator-(difference_type off) const - { return *this + (-off); } - - typename UnaryFunction::result_type operator*() const - { return dereference(); } - - typename UnaryFunction::result_type operator[](difference_type off) const - { return UnaryFunction::operator()(m_it[off]); } - - operator_arrow_proxy - operator->() const - { return operator_arrow_proxy(dereference()); } - - Iterator & base() - { return m_it; } - - const Iterator & base() const - { return m_it; } - - private: - Iterator m_it; - - void increment() - { ++m_it; } - - void decrement() - { --m_it; } - - bool equal(const transform_iterator &other) const - { return m_it == other.m_it; } - - bool less(const transform_iterator &other) const - { return other.m_it < m_it; } - - typename UnaryFunction::result_type dereference() const - { return UnaryFunction::operator()(*m_it); } - - void advance(difference_type n) - { ::boost::container::iterator_advance(m_it, n); } - - difference_type distance_to(const transform_iterator &other)const - { return ::boost::container::iterator_distance(other.m_it, m_it); } -}; - -template -transform_iterator -make_transform_iterator(Iterator it, UnaryFunc fun) -{ - return transform_iterator(it, fun); -} +using boost::container::make_transform_iterator; +using boost::container::transform_iterator; } //namespace interprocess { } //namespace boost { diff --git a/include/boost/interprocess/detail/variadic_templates_tools.hpp b/include/boost/interprocess/detail/variadic_templates_tools.hpp index c0f5913..936f702 100644 --- a/include/boost/interprocess/detail/variadic_templates_tools.hpp +++ b/include/boost/interprocess/detail/variadic_templates_tools.hpp @@ -25,10 +25,10 @@ namespace boost { namespace interprocess { namespace ipcdetail { -using boost::container::container_detail::tuple; -using boost::container::container_detail::build_number_seq; -using boost::container::container_detail::index_tuple; -using boost::container::container_detail::get; +using boost::container::dtl::tuple; +using boost::container::dtl::build_number_seq; +using boost::container::dtl::index_tuple; +using boost::container::dtl::get; }}} //namespace boost { namespace interprocess { namespace ipcdetail { diff --git a/include/boost/interprocess/detail/win32_api.hpp b/include/boost/interprocess/detail/win32_api.hpp index 1ea8cec..d12097f 100644 --- a/include/boost/interprocess/detail/win32_api.hpp +++ b/include/boost/interprocess/detail/win32_api.hpp @@ -2035,7 +2035,7 @@ inline bool get_registry_value_string(hkey key_type, const char *subkey_name, co unsigned long size; unsigned long type; long err = reg_query_value_ex( key, value_name, 0, &type, 0, &size); - if((reg_sz == type || reg_expand_sz != type) && !err){ + if((reg_sz == type || reg_expand_sz == type) && !err){ //Size includes terminating NULL s.resize(size); err = reg_query_value_ex( key, value_name, 0, &type, (unsigned char*)(&s[0]), &size); diff --git a/include/boost/interprocess/detail/workaround.hpp b/include/boost/interprocess/detail/workaround.hpp index bdee15a..53cd3eb 100644 --- a/include/boost/interprocess/detail/workaround.hpp +++ b/include/boost/interprocess/detail/workaround.hpp @@ -31,7 +31,7 @@ ////////////////////////////////////////////////////// //Check for XSI shared memory objects. They are available in nearly all UNIX platforms ////////////////////////////////////////////////////// - #if !defined(__QNXNTO__) && !defined(__ANDROID__) && !defined(__HAIKU__) + #if !defined(__QNXNTO__) && !defined(__ANDROID__) && !defined(__HAIKU__) && !(__VXWORKS__) #define BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS #endif diff --git a/include/boost/interprocess/ipc/message_queue.hpp b/include/boost/interprocess/ipc/message_queue.hpp index db422cc..da45ad4 100644 --- a/include/boost/interprocess/ipc/message_queue.hpp +++ b/include/boost/interprocess/ipc/message_queue.hpp @@ -74,7 +74,7 @@ class message_queue_t pointer_traits::template rebind_pointer::type char_ptr; typedef typename boost::intrusive::pointer_traits::difference_type difference_type; - typedef typename boost::container::container_detail::make_unsigned::type size_type; + typedef typename boost::container::dtl::make_unsigned::type size_type; //!Creates a process shared message queue with name "name". For this message queue, //!the maximum number of messages will be "max_num_msg" and the maximum message size @@ -211,7 +211,7 @@ class msg_hdr_t pointer_traits::template rebind_pointer::type char_ptr; typedef typename boost::intrusive::pointer_traits::difference_type difference_type; - typedef typename boost::container::container_detail::make_unsigned::type size_type; + typedef typename boost::container::dtl::make_unsigned::type size_type; public: size_type len; // Message length @@ -297,7 +297,7 @@ class mq_hdr_t typedef typename boost::intrusive::pointer_traits ::difference_type difference_type; typedef typename boost::container:: - container_detail::make_unsigned::type size_type; + dtl::make_unsigned::type size_type; typedef typename boost::intrusive:: pointer_traits::template rebind_pointer::type msg_hdr_ptr_ptr_t; @@ -529,8 +529,8 @@ class mq_hdr_t (size_type max_msg_size, size_type max_num_msg) { const size_type - msg_hdr_align = ::boost::container::container_detail::alignment_of::value, - index_align = ::boost::container::container_detail::alignment_of::value, + msg_hdr_align = ::boost::container::dtl::alignment_of::value, + index_align = ::boost::container::dtl::alignment_of::value, r_hdr_size = ipcdetail::ct_rounded_size::value, r_index_size = ipcdetail::get_rounded_size(max_num_msg*sizeof(msg_hdr_ptr_t), msg_hdr_align), r_max_msg_size = ipcdetail::get_rounded_size(max_msg_size, msg_hdr_align) + sizeof(msg_header); @@ -543,8 +543,8 @@ class mq_hdr_t void initialize_memory() { const size_type - msg_hdr_align = ::boost::container::container_detail::alignment_of::value, - index_align = ::boost::container::container_detail::alignment_of::value, + msg_hdr_align = ::boost::container::dtl::alignment_of::value, + index_align = ::boost::container::dtl::alignment_of::value, r_hdr_size = ipcdetail::ct_rounded_size::value, r_index_size = ipcdetail::get_rounded_size(m_max_num_msg*sizeof(msg_hdr_ptr_t), msg_hdr_align), r_max_msg_size = ipcdetail::get_rounded_size(m_max_msg_size, msg_hdr_align) + sizeof(msg_header); @@ -603,7 +603,7 @@ class msg_queue_initialization_func_t rebind_pointer::type char_ptr; typedef typename boost::intrusive::pointer_traits:: difference_type difference_type; - typedef typename boost::container::container_detail:: + typedef typename boost::container::dtl:: make_unsigned::type size_type; msg_queue_initialization_func_t(size_type maxmsg = 0, diff --git a/include/boost/interprocess/mem_algo/detail/mem_algo_common.hpp b/include/boost/interprocess/mem_algo/detail/mem_algo_common.hpp index 87293d1..eda4cf1 100644 --- a/include/boost/interprocess/mem_algo/detail/mem_algo_common.hpp +++ b/include/boost/interprocess/mem_algo/detail/mem_algo_common.hpp @@ -48,11 +48,11 @@ namespace ipcdetail { template class basic_multiallocation_chain - : public boost::container::container_detail:: + : public boost::container::dtl:: basic_multiallocation_chain { BOOST_MOVABLE_BUT_NOT_COPYABLE(basic_multiallocation_chain) - typedef boost::container::container_detail:: + typedef boost::container::dtl:: basic_multiallocation_chain base_t; public: diff --git a/include/boost/interprocess/mem_algo/detail/simple_seq_fit_impl.hpp b/include/boost/interprocess/mem_algo/detail/simple_seq_fit_impl.hpp index 5c7a420..b8b7846 100644 --- a/include/boost/interprocess/mem_algo/detail/simple_seq_fit_impl.hpp +++ b/include/boost/interprocess/mem_algo/detail/simple_seq_fit_impl.hpp @@ -72,11 +72,11 @@ class simple_seq_fit_impl typedef MutexFamily mutex_family; //!Pointer type to be used with the rest of the Interprocess framework typedef VoidPointer void_pointer; - typedef boost::container::container_detail:: + typedef boost::container::dtl:: basic_multiallocation_chain multiallocation_chain; typedef typename boost::intrusive::pointer_traits::difference_type difference_type; - typedef typename boost::container::container_detail::make_unsigned::type size_type; + typedef typename boost::container::dtl::make_unsigned::type size_type; private: @@ -270,8 +270,8 @@ class simple_seq_fit_impl void priv_mark_new_allocated_block(block_ctrl *block); public: - static const size_type Alignment = ::boost::container::container_detail::alignment_of - < ::boost::container::container_detail::max_align_t>::value; + static const size_type Alignment = ::boost::container::dtl::alignment_of + < ::boost::container::dtl::max_align_t>::value; private: static const size_type BlockCtrlBytes = ipcdetail::ct_rounded_size::value; static const size_type BlockCtrlUnits = BlockCtrlBytes/Alignment; @@ -590,7 +590,7 @@ inline T* simple_seq_fit_impl:: void *raw_reuse = reuse_ptr; void * const ret = priv_allocation_command (command, limit_size, prefer_in_recvd_out_size, raw_reuse, sizeof(T)); - BOOST_ASSERT(0 == ((std::size_t)ret % ::boost::container::container_detail::alignment_of::value)); + BOOST_ASSERT(0 == ((std::size_t)ret % ::boost::container::dtl::alignment_of::value)); reuse_ptr = static_cast(raw_reuse); return static_cast(ret); } diff --git a/include/boost/interprocess/mem_algo/rbtree_best_fit.hpp b/include/boost/interprocess/mem_algo/rbtree_best_fit.hpp index 7ad9d74..7da31f7 100644 --- a/include/boost/interprocess/mem_algo/rbtree_best_fit.hpp +++ b/include/boost/interprocess/mem_algo/rbtree_best_fit.hpp @@ -94,7 +94,7 @@ class rbtree_best_fit typedef ipcdetail::basic_multiallocation_chain multiallocation_chain; typedef typename boost::intrusive::pointer_traits::difference_type difference_type; - typedef typename boost::container::container_detail::make_unsigned::type size_type; + typedef typename boost::container::dtl::make_unsigned::type size_type; #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) @@ -331,8 +331,8 @@ class rbtree_best_fit public: static const size_type Alignment = !MemAlignment - ? size_type(::boost::container::container_detail::alignment_of - < ::boost::container::container_detail::max_align_t>::value) + ? size_type(::boost::container::dtl::alignment_of + < ::boost::container::dtl::max_align_t>::value) : size_type(MemAlignment) ; @@ -340,7 +340,7 @@ class rbtree_best_fit //Due to embedded bits in size, Alignment must be at least 4 BOOST_STATIC_ASSERT((Alignment >= 4)); //Due to rbtree size optimizations, Alignment must have at least pointer alignment - BOOST_STATIC_ASSERT((Alignment >= ::boost::container::container_detail::alignment_of::value)); + BOOST_STATIC_ASSERT((Alignment >= ::boost::container::dtl::alignment_of::value)); static const size_type AlignmentMask = (Alignment - 1); static const size_type BlockCtrlBytes = ipcdetail::ct_rounded_size::value; static const size_type BlockCtrlUnits = BlockCtrlBytes/Alignment; @@ -692,7 +692,7 @@ inline T* rbtree_best_fit:: void* raw_reuse = reuse; void* const ret = priv_allocation_command(command, limit_size, prefer_in_recvd_out_size, raw_reuse, sizeof(T)); reuse = static_cast(raw_reuse); - BOOST_ASSERT(0 == ((std::size_t)ret % ::boost::container::container_detail::alignment_of::value)); + BOOST_ASSERT(0 == ((std::size_t)ret % ::boost::container::dtl::alignment_of::value)); return static_cast(ret); } diff --git a/include/boost/interprocess/offset_ptr.hpp b/include/boost/interprocess/offset_ptr.hpp index 24b044a..66d38cc 100644 --- a/include/boost/interprocess/offset_ptr.hpp +++ b/include/boost/interprocess/offset_ptr.hpp @@ -66,7 +66,7 @@ namespace ipcdetail { OffsetType m_offset; //Distance between this object and pointee address - typename ::boost::container::container_detail::aligned_storage + typename ::boost::container::dtl::aligned_storage < sizeof(OffsetType)//for offset_type_alignment m_offset will be enough , (OffsetAlignment == offset_type_alignment) ? 1u : OffsetAlignment >::type alignment_helper; diff --git a/include/boost/interprocess/segment_manager.hpp b/include/boost/interprocess/segment_manager.hpp index d00f177..8e2221e 100644 --- a/include/boost/interprocess/segment_manager.hpp +++ b/include/boost/interprocess/segment_manager.hpp @@ -630,7 +630,7 @@ class segment_manager //!the named allocations performed in this segment manager const_named_iterator named_begin() const { - return make_transform_iterator + return (make_transform_iterator) (m_header.m_named_index.begin(), named_transform()); } @@ -638,7 +638,7 @@ class segment_manager //!the named allocations performed in this segment manager const_named_iterator named_end() const { - return make_transform_iterator + return (make_transform_iterator) (m_header.m_named_index.end(), named_transform()); } @@ -646,7 +646,7 @@ class segment_manager //!the unique allocations performed in this segment manager const_unique_iterator unique_begin() const { - return make_transform_iterator + return (make_transform_iterator) (m_header.m_unique_index.begin(), unique_transform()); } @@ -654,7 +654,7 @@ class segment_manager //!the unique allocations performed in this segment manager const_unique_iterator unique_end() const { - return make_transform_iterator + return (make_transform_iterator) (m_header.m_unique_index.end(), unique_transform()); } diff --git a/include/boost/interprocess/smart_ptr/intrusive_ptr.hpp b/include/boost/interprocess/smart_ptr/intrusive_ptr.hpp old mode 100644 new mode 100755 index e2cf45f..585b995 --- a/include/boost/interprocess/smart_ptr/intrusive_ptr.hpp +++ b/include/boost/interprocess/smart_ptr/intrusive_ptr.hpp @@ -32,6 +32,7 @@ #include #include #include +#include #include // for std::basic_ostream @@ -48,8 +49,8 @@ namespace interprocess { //!intrusive_ptr > defines a class with a offset_ptr member. //!Relies on unqualified calls to: //! -//! void intrusive_ptr_add_ref(T * p); -//! void intrusive_ptr_release(T * p); +//! void intrusive_ptr_add_ref(T * p) BOOST_NOEXCEPT; +//! void intrusive_ptr_release(T * p) BOOST_NOEXCEPT; //! //! with (p != 0) //! @@ -72,56 +73,73 @@ class intrusive_ptr typedef pointer this_type::*unspecified_bool_type; #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED + BOOST_COPYABLE_AND_MOVABLE(intrusive_ptr) + public: //!Constructor. Initializes internal pointer to 0. //!Does not throw - intrusive_ptr(): m_ptr(0) + intrusive_ptr() BOOST_NOEXCEPT + : m_ptr(0) {} //!Constructor. Copies pointer and if "p" is not zero and //!"add_ref" is true calls intrusive_ptr_add_ref(to_raw_pointer(p)). //!Does not throw - intrusive_ptr(const pointer &p, bool add_ref = true): m_ptr(p) + intrusive_ptr(const pointer &p, bool add_ref = true) BOOST_NOEXCEPT + : m_ptr(p) { if(m_ptr != 0 && add_ref) intrusive_ptr_add_ref(ipcdetail::to_raw_pointer(m_ptr)); } //!Copy constructor. Copies the internal pointer and if "p" is not //!zero calls intrusive_ptr_add_ref(to_raw_pointer(p)). Does not throw - intrusive_ptr(intrusive_ptr const & rhs) + intrusive_ptr(intrusive_ptr const & rhs) BOOST_NOEXCEPT : m_ptr(rhs.m_ptr) { if(m_ptr != 0) intrusive_ptr_add_ref(ipcdetail::to_raw_pointer(m_ptr)); } + //!Move constructor. Moves the internal pointer. Does not throw + intrusive_ptr(BOOST_RV_REF(intrusive_ptr) rhs) BOOST_NOEXCEPT + : m_ptr(rhs.m_ptr) + { + rhs.m_ptr = 0; + } + //!Constructor from related. Copies the internal pointer and if "p" is not //!zero calls intrusive_ptr_add_ref(to_raw_pointer(p)). Does not throw - template intrusive_ptr - (intrusive_ptr const & rhs) + template intrusive_ptr(intrusive_ptr const & rhs) BOOST_NOEXCEPT : m_ptr(rhs.get()) { if(m_ptr != 0) intrusive_ptr_add_ref(ipcdetail::to_raw_pointer(m_ptr)); } - //!Destructor. If internal pointer is not 0, calls - //!intrusive_ptr_release(to_raw_pointer(m_ptr)). Does not throw + //!Destructor. Calls reset(). Does not throw ~intrusive_ptr() { - if(m_ptr != 0) intrusive_ptr_release(ipcdetail::to_raw_pointer(m_ptr)); + reset(); } //!Assignment operator. Equivalent to intrusive_ptr(r).swap(*this). //!Does not throw - intrusive_ptr & operator=(intrusive_ptr const & rhs) + intrusive_ptr & operator=(BOOST_COPY_ASSIGN_REF(intrusive_ptr) rhs) BOOST_NOEXCEPT { this_type(rhs).swap(*this); return *this; } + //!Move Assignment operator + //!Does not throw + intrusive_ptr & operator=(BOOST_RV_REF(intrusive_ptr) rhs) BOOST_NOEXCEPT + { + rhs.swap(*this); + rhs.reset(); + return *this; + } + //!Assignment from related. Equivalent to intrusive_ptr(r).swap(*this). //!Does not throw - template intrusive_ptr & operator= - (intrusive_ptr const & rhs) + template intrusive_ptr & operator=(intrusive_ptr const & rhs) BOOST_NOEXCEPT { this_type(rhs).swap(*this); return *this; @@ -129,50 +147,60 @@ class intrusive_ptr //!Assignment from pointer. Equivalent to intrusive_ptr(r).swap(*this). //!Does not throw - intrusive_ptr & operator=(pointer rhs) + intrusive_ptr & operator=(pointer rhs) BOOST_NOEXCEPT { this_type(rhs).swap(*this); return *this; } + //!Release internal pointer and set it to 0. If internal pointer is not 0, calls + //!intrusive_ptr_release(to_raw_pointer(m_ptr)). Does not throw + void reset() BOOST_NOEXCEPT { + if(m_ptr != 0) { + pointer ptr = m_ptr; + m_ptr = 0; + intrusive_ptr_release(ipcdetail::to_raw_pointer(ptr)); + } + } + //!Returns a reference to the internal pointer. //!Does not throw - pointer &get() + pointer &get() BOOST_NOEXCEPT { return m_ptr; } //!Returns a reference to the internal pointer. //!Does not throw - const pointer &get() const + const pointer &get() const BOOST_NOEXCEPT { return m_ptr; } //!Returns *get(). //!Does not throw - T & operator*() const + T & operator*() const BOOST_NOEXCEPT { return *m_ptr; } //!Returns *get(). //!Does not throw - const pointer &operator->() const + const pointer &operator->() const BOOST_NOEXCEPT { return m_ptr; } //!Returns get(). //!Does not throw - pointer &operator->() + pointer &operator->() BOOST_NOEXCEPT { return m_ptr; } //!Conversion to boolean. //!Does not throw - operator unspecified_bool_type () const + operator unspecified_bool_type () const BOOST_NOEXCEPT { return m_ptr == 0? 0: &this_type::m_ptr; } //!Not operator. //!Does not throw - bool operator! () const + bool operator! () const BOOST_NOEXCEPT { return m_ptr == 0; } //!Exchanges the contents of the two smart pointers. //!Does not throw - void swap(intrusive_ptr & rhs) + void swap(intrusive_ptr & rhs) BOOST_NOEXCEPT { ::boost::adl_move_swap(m_ptr, rhs.m_ptr); } #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) @@ -185,49 +213,49 @@ class intrusive_ptr //!Does not throw template inline bool operator==(intrusive_ptr const & a, - intrusive_ptr const & b) + intrusive_ptr const & b) BOOST_NOEXCEPT { return a.get() == b.get(); } //!Returns a.get() != b.get(). //!Does not throw template inline bool operator!=(intrusive_ptr const & a, - intrusive_ptr const & b) + intrusive_ptr const & b) BOOST_NOEXCEPT { return a.get() != b.get(); } //!Returns a.get() == b. //!Does not throw template inline bool operator==(intrusive_ptr const & a, - const typename intrusive_ptr::pointer &b) + const typename intrusive_ptr::pointer &b) BOOST_NOEXCEPT { return a.get() == b; } //!Returns a.get() != b. //!Does not throw template inline bool operator!=(intrusive_ptr const & a, - const typename intrusive_ptr::pointer &b) + const typename intrusive_ptr::pointer &b) BOOST_NOEXCEPT { return a.get() != b; } //!Returns a == b.get(). //!Does not throw template inline bool operator==(const typename intrusive_ptr::pointer &a, - intrusive_ptr const & b) + intrusive_ptr const & b) BOOST_NOEXCEPT { return a == b.get(); } //!Returns a != b.get(). //!Does not throw template inline bool operator!=(const typename intrusive_ptr::pointer &a, - intrusive_ptr const & b) + intrusive_ptr const & b) BOOST_NOEXCEPT { return a != b.get(); } //!Returns a.get() < b.get(). //!Does not throw template inline bool operator<(intrusive_ptr const & a, - intrusive_ptr const & b) + intrusive_ptr const & b) BOOST_NOEXCEPT { return std::less::pointer>() (a.get(), b.get()); @@ -237,34 +265,34 @@ bool operator<(intrusive_ptr const & a, //!Does not throw template inline void swap(intrusive_ptr & lhs, - intrusive_ptr & rhs) + intrusive_ptr & rhs) BOOST_NOEXCEPT { lhs.swap(rhs); } // operator<< template inline std::basic_ostream & operator<< - (std::basic_ostream & os, intrusive_ptr const & p) + (std::basic_ostream & os, intrusive_ptr const & p) BOOST_NOEXCEPT { os << p.get(); return os; } //!Returns p.get(). //!Does not throw template inline typename boost::interprocess::intrusive_ptr::pointer - to_raw_pointer(intrusive_ptr p) + to_raw_pointer(intrusive_ptr p) BOOST_NOEXCEPT { return p.get(); } /*Emulates static cast operator. Does not throw*/ /* template inline boost::interprocess::intrusive_ptr static_pointer_cast - (boost::interprocess::intrusive_ptr const & p) + (boost::interprocess::intrusive_ptr const & p) BOOST_NOEXCEPT { return do_static_cast(p.get()); } */ /*Emulates const cast operator. Does not throw*/ /* template inline boost::interprocess::intrusive_ptr const_pointer_cast - (boost::interprocess::intrusive_ptr const & p) + (boost::interprocess::intrusive_ptr const & p) BOOST_NOEXCEPT { return do_const_cast(p.get()); } */ @@ -272,7 +300,7 @@ inline boost::interprocess::intrusive_ptr const_pointer_cast /* template inline boost::interprocess::intrusive_ptr dynamic_pointer_cast - (boost::interprocess::intrusive_ptr const & p) + (boost::interprocess::intrusive_ptr const & p) BOOST_NOEXCEPT { return do_dynamic_cast(p.get()); } */ @@ -280,7 +308,7 @@ inline boost::interprocess::intrusive_ptr dynamic_pointer_cast /* template inline boost::interprocess::intrusive_ptrreinterpret_pointer_cast - (boost::interprocess::intrusive_ptr const & p) + (boost::interprocess::intrusive_ptr const & p) BOOST_NOEXCEPT { return do_reinterpret_cast(p.get()); } */ @@ -292,7 +320,7 @@ inline boost::interprocess::intrusive_ptrreinterpret_pointer_cast //!Returns p.get(). //!Does not throw template -inline T *to_raw_pointer(boost::interprocess::intrusive_ptr p) +inline T *to_raw_pointer(boost::interprocess::intrusive_ptr p) BOOST_NOEXCEPT { return p.get(); } #endif diff --git a/include/boost/interprocess/sync/detail/common_algorithms.hpp b/include/boost/interprocess/sync/detail/common_algorithms.hpp index 1a72d68..87739b8 100644 --- a/include/boost/interprocess/sync/detail/common_algorithms.hpp +++ b/include/boost/interprocess/sync/detail/common_algorithms.hpp @@ -72,6 +72,49 @@ void try_based_lock(MutexType &m) } } +template +void timed_based_lock(MutexType &m, unsigned const uCheckPeriodSec) +{ + const boost::posix_time::time_duration dur(0, 0, uCheckPeriodSec); + boost::posix_time::ptime deadline(microsec_clock::universal_time()+dur); + if(!m.timed_lock(deadline)){ + spin_wait swait; + do{ + deadline = microsec_clock::universal_time()+dur; + if(m.timed_lock(deadline)){ + break; + } + else{ + swait.yield(); + } + } + while(1); + } +} + +template +void timed_based_timed_lock(MutexType &m, const boost::posix_time::ptime &abs_time, unsigned const uCheckPeriodSec) +{ + const boost::posix_time::time_duration dur(0, 0, uCheckPeriodSec); + boost::posix_time::ptime deadline(microsec_clock::universal_time()+dur); + if(abs_time <= deadline){ + m.timed_lock(abs_time); + } + else if(!m.timed_lock(deadline)){ + spin_wait swait; + do{ + deadline = microsec_clock::universal_time()+dur; + if(m.timed_lock(deadline)){ + break; + } + else{ + swait.yield(); + } + } + while(1); + } +} + } //namespace ipcdetail } //namespace interprocess } //namespace boost diff --git a/test/check_equal_containers.hpp b/test/check_equal_containers.hpp index 80fe93f..423a84c 100644 --- a/test/check_equal_containers.hpp +++ b/test/check_equal_containers.hpp @@ -22,17 +22,17 @@ namespace test{ template< class T1, class T2> bool CheckEqual( const T1 &t1, const T2 &t2 - , typename boost::container::container_detail::enable_if_c - ::value && - !boost::container::container_detail::is_pair::value + , typename boost::container::dtl::enable_if_c + ::value && + !boost::container::dtl::is_pair::value >::type* = 0) { return t1 == t2; } template< class Pair1, class Pair2> bool CheckEqual( const Pair1 &pair1, const Pair2 &pair2 - , typename boost::container::container_detail::enable_if_c - ::value && - boost::container::container_detail::is_pair::value + , typename boost::container::dtl::enable_if_c + ::value && + boost::container::dtl::is_pair::value >::type* = 0) { return CheckEqual(pair1.first, pair2.first) && CheckEqual(pair1.second, pair2.second); diff --git a/test/emplace_test.hpp b/test/emplace_test.hpp index 3557c6f..71cb288 100644 --- a/test/emplace_test.hpp +++ b/test/emplace_test.hpp @@ -142,7 +142,7 @@ bool test_expected_container(const Container &ec, const std::pair EmplaceIntPair; -static boost::container::container_detail::aligned_storage::type pair_storage; +static boost::container::dtl::aligned_storage::type pair_storage; static EmplaceIntPair* initialize_emplace_int_pair() { diff --git a/test/intrusive_ptr_test.cpp b/test/intrusive_ptr_test.cpp index d5293a3..f3e4812 100644 --- a/test/intrusive_ptr_test.cpp +++ b/test/intrusive_ptr_test.cpp @@ -17,10 +17,15 @@ #include #include #include +#include #include typedef boost::interprocess::offset_ptr VP; +namespace { + int addref_release_calls = 0; +} + namespace N { @@ -52,11 +57,13 @@ class base void add_ref() { + ++addref_release_calls; ++use_count_; } void release() { + ++addref_release_calls; if(--use_count_ == 0) delete this; } }; @@ -189,11 +196,30 @@ void copy_constructor() } } +void move_constructor() +{ + { + int prev_addref_release_calls = addref_release_calls; + X* x = new X(); + boost::interprocess::intrusive_ptr px(x); + BOOST_TEST(addref_release_calls == prev_addref_release_calls + 1); + + //static_assert(std::is_nothrow_move_constructible< boost::interprocess::intrusive_ptr >::value, "test instrusive_ptr is nothrow move constructible"); + + boost::interprocess::intrusive_ptr px2(boost::move(px)); + BOOST_TEST(px2.get() == x); + BOOST_TEST(!px.get()); + BOOST_TEST(px2->use_count() == 1); + BOOST_TEST(addref_release_calls == prev_addref_release_calls + 1); + } +} + void test() { default_constructor(); pointer_constructor(); copy_constructor(); + move_constructor(); } } // namespace n_constructors @@ -223,6 +249,26 @@ void copy_assignment() { } +void move_assignment() +{ + { + int prev_addref_release_calls = addref_release_calls; + X* x = new X(); + boost::interprocess::intrusive_ptr px(x); + BOOST_TEST(px->use_count() == 1); + BOOST_TEST(addref_release_calls == prev_addref_release_calls + 1); + + //static_assert(std::is_nothrow_move_assignable< boost::interprocess::intrusive_ptr >::value, "test if nothrow move assignable "); + + boost::interprocess::intrusive_ptr px2; + px2 = boost::move(px); + BOOST_TEST(px2.get() == x); + BOOST_TEST(!px.get()); + BOOST_TEST(px2->use_count() == 1); + BOOST_TEST(addref_release_calls == prev_addref_release_calls + 1); + } +} + void conversion_assignment() { } @@ -236,6 +282,7 @@ void test() copy_assignment(); conversion_assignment(); pointer_assignment(); + move_assignment(); } } // namespace n_assignment diff --git a/test/memory_algorithm_test.cpp b/test/memory_algorithm_test.cpp index 4e3c6e4..9210640 100644 --- a/test/memory_algorithm_test.cpp +++ b/test/memory_algorithm_test.cpp @@ -69,7 +69,7 @@ int test_rbtree_best_fit() int main () { - const std::size_t void_ptr_align = ::boost::container::container_detail::alignment_of >::value; + const std::size_t void_ptr_align = ::boost::container::dtl::alignment_of >::value; if(test_simple_seq_fit()){ return 1; diff --git a/test/shared_ptr_test.cpp b/test/shared_ptr_test.cpp index 5bdfd93..b523acc 100644 --- a/test/shared_ptr_test.cpp +++ b/test/shared_ptr_test.cpp @@ -48,10 +48,9 @@ class derived_class int simple_test() { - typedef allocator - base_class_allocator; - typedef deleter - base_deleter_t; + typedef managed_shared_memory::segment_manager segment_mngr_t; + typedef allocator base_class_allocator; + typedef deleter base_deleter_t; typedef shared_ptr base_shared_ptr; std::string process_name; @@ -97,35 +96,31 @@ int simple_test() int string_shared_ptr_vector_insertion_test() { + typedef managed_shared_memory::segment_manager segment_mngr_t; + //Allocator of chars - typedef allocator - char_allocator_t; + typedef allocator char_allocator_t; //A shared memory string class - typedef basic_string, - char_allocator_t> string_t; + typedef basic_string, char_allocator_t> string_t; //A shared memory string allocator - typedef allocator - string_allocator_t; + typedef allocator string_allocator_t; //A deleter for shared_ptr<> that erases a shared memory string - typedef deleter - string_deleter_t; + typedef deleter string_deleter_t; //A shared pointer that points to a shared memory string and its instantiation typedef shared_ptr string_shared_ptr_t; //An allocator for shared pointers to a string in shared memory - typedef allocator - string_shared_ptr_allocator_t; + typedef allocator string_shared_ptr_allocator_t; //A weak pointer that points to a shared memory string and its instantiation typedef weak_ptr string_weak_ptr_t; //An allocator for weak pointers to a string in shared memory - typedef allocator - string_weak_ptr_allocator_t; + typedef allocator string_weak_ptr_allocator_t; //A vector of shared pointers to strings (all in shared memory) and its instantiation typedef vector @@ -156,8 +151,7 @@ int string_shared_ptr_vector_insertion_test() //Create a string in shared memory, to avoid leaks with exceptions use //scoped ptr until we store this pointer in the shared ptr scoped_ptr scoped_string - (shmem.construct(anonymous_instance)(string_allocator), - deleter); + (shmem.construct(anonymous_instance)(string_allocator), deleter); //Now construct a shared pointer to a string string_shared_ptr_t string_shared_ptr (scoped_string.get(), string_shared_ptr_allocator, @@ -262,6 +256,7 @@ int string_shared_ptr_vector_insertion_test() shared_memory_object::remove(process_name.c_str()); return 0; } + // // This part is taken from shared_ptr_basic_test.cpp // @@ -402,21 +397,13 @@ void test_is_nonzero(shared_ptr const & p) int basic_shared_ptr_test() { - typedef allocator - v_allocator_t; - - typedef deleter - x_deleter_t; - - typedef deleter - y_deleter_t; - + typedef managed_shared_memory::segment_manager segment_mngr_t; + typedef allocator v_allocator_t; + typedef deleter x_deleter_t; + typedef deleter y_deleter_t; typedef shared_ptr x_shared_ptr; - typedef shared_ptr y_shared_ptr; - typedef weak_ptr x_weak_ptr; - typedef weak_ptr y_weak_ptr; std::string process_name; @@ -557,11 +544,9 @@ struct alias_tester void test_alias() { - typedef allocator - v_allocator_t; - - typedef deleter - int_deleter_t; + typedef managed_shared_memory::segment_manager segment_mngr_t; + typedef allocator v_allocator_t; + typedef deleter int_deleter_t; typedef shared_ptr int_shared_ptr; typedef shared_ptr const_int_shared_ptr; diff --git a/test/user_buffer_test.cpp b/test/user_buffer_test.cpp index 8adfcc9..32670af 100644 --- a/test/user_buffer_test.cpp +++ b/test/user_buffer_test.cpp @@ -53,9 +53,9 @@ bool CheckEqual(MyUserList *userlist, MyStdList *stdlist, MyHeapList *heaplist) int main () { //Create the user memory who will store all objects - const int size_aligner = sizeof(::boost::container::container_detail::max_align_t); + const int size_aligner = sizeof(::boost::container::dtl::max_align_t); const int memsize = 65536/size_aligner*size_aligner; - static ::boost::container::container_detail::max_align_t static_buffer[memsize/size_aligner]; + static ::boost::container::dtl::max_align_t static_buffer[memsize/size_aligner]; { //Now test move semantics