mirror of
https://github.com/boostorg/interprocess.git
synced 2026-01-19 04:12:13 +00:00
merging interprocess from develop
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -102,7 +102,7 @@ class adaptive_pool_base
|
||||
typedef typename segment_manager::difference_type difference_type;
|
||||
|
||||
typedef boost::interprocess::version_type<adaptive_pool_base, Version> version;
|
||||
typedef boost::container::container_detail::transform_multiallocation_chain
|
||||
typedef boost::container::dtl::transform_multiallocation_chain
|
||||
<typename SegmentManager::multiallocation_chain, T>multiallocation_chain;
|
||||
|
||||
//!Obtains adaptive_pool_base from
|
||||
|
||||
@@ -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
|
||||
<typename SegmentManager::multiallocation_chain, T>multiallocation_chain;
|
||||
#endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -328,7 +328,7 @@ class array_allocation_impl
|
||||
<const value_type>::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
|
||||
<typename SegmentManager::multiallocation_chain, T>multiallocation_chain;
|
||||
|
||||
|
||||
@@ -442,7 +442,7 @@ class node_pool_allocation_impl
|
||||
<const value_type>::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
|
||||
<typename SegmentManager::multiallocation_chain, T>multiallocation_chain;
|
||||
|
||||
|
||||
|
||||
@@ -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<typename SegmentManager::segment_manager_base_type>
|
||||
{
|
||||
typedef boost::container::container_detail::private_node_pool_impl
|
||||
typedef boost::container::dtl::private_node_pool_impl
|
||||
<typename SegmentManager::segment_manager_base_type> base_t;
|
||||
//Non-copyable
|
||||
private_node_pool();
|
||||
|
||||
@@ -99,7 +99,7 @@ class node_allocator_base
|
||||
typedef typename segment_manager::difference_type difference_type;
|
||||
|
||||
typedef boost::interprocess::version_type<node_allocator_base, Version> version;
|
||||
typedef boost::container::container_detail::transform_multiallocation_chain
|
||||
typedef boost::container::dtl::transform_multiallocation_chain
|
||||
<typename SegmentManager::multiallocation_chain, T>multiallocation_chain;
|
||||
|
||||
//!Obtains node_allocator_base from
|
||||
|
||||
@@ -100,7 +100,7 @@ class private_adaptive_pool_base
|
||||
typedef typename segment_manager::size_type difference_type;
|
||||
typedef boost::interprocess::version_type
|
||||
<private_adaptive_pool_base, Version> version;
|
||||
typedef boost::container::container_detail::transform_multiallocation_chain
|
||||
typedef boost::container::dtl::transform_multiallocation_chain
|
||||
<typename SegmentManager::multiallocation_chain, T>multiallocation_chain;
|
||||
|
||||
//!Obtains node_allocator from other node_allocator
|
||||
|
||||
@@ -95,7 +95,7 @@ class private_node_allocator_base
|
||||
typedef typename segment_manager::difference_type difference_type;
|
||||
typedef boost::interprocess::version_type
|
||||
<private_node_allocator_base, Version> version;
|
||||
typedef boost::container::container_detail::transform_multiallocation_chain
|
||||
typedef boost::container::dtl::transform_multiallocation_chain
|
||||
<typename SegmentManager::multiallocation_chain, T>multiallocation_chain;
|
||||
|
||||
//!Obtains node_allocator from other node_allocator
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
namespace boost {
|
||||
namespace interprocess {
|
||||
|
||||
using boost::container::container_detail::pair;
|
||||
using boost::container::dtl::pair;
|
||||
|
||||
} //namespace interprocess {
|
||||
} //namespace boost {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 <vxAtomicLib.h>
|
||||
// VxWorks atomic32_t is not volatile, for some unknown reason
|
||||
#define vx_atomic_cast(_i) (reinterpret_cast< ::atomic32_t *>( const_cast<boost::uint32_t *>(_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{
|
||||
|
||||
@@ -51,7 +51,7 @@ template<class T>
|
||||
struct placement_destroy : public in_place_interface
|
||||
{
|
||||
placement_destroy()
|
||||
: in_place_interface(::boost::container::container_detail::alignment_of<T>::value, sizeof(T), typeid(T).name())
|
||||
: in_place_interface(::boost::container::dtl::alignment_of<T>::value, sizeof(T), typeid(T).name())
|
||||
{}
|
||||
|
||||
virtual void destroy_n(void *mem, std::size_t num, std::size_t &destroyed)
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -274,7 +274,7 @@ class named_proxy
|
||||
T *operator()( BOOST_MOVE_UREF##N ) const\
|
||||
{\
|
||||
typedef typename if_c<is_iterator \
|
||||
, CtorIt##N<T BOOST_MOVE_I##N BOOST_MOVE_TARG##N> \
|
||||
, CtorIt##N <T BOOST_MOVE_I##N BOOST_MOVE_TARG##N> \
|
||||
, CtorArg##N<T BOOST_MOVE_I##N BOOST_MOVE_TARG##N> \
|
||||
>::type ctor_obj_t;\
|
||||
ctor_obj_t ctor_obj = ctor_obj_t( BOOST_MOVE_FWD##N );\
|
||||
|
||||
@@ -52,6 +52,9 @@
|
||||
# include <sys/param.h>
|
||||
# include <sys/sysctl.h>
|
||||
# endif
|
||||
#if defined(__VXWORKS__)
|
||||
#include <vxCpuLib.h>
|
||||
#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<unsigned int>(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
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ struct block_header
|
||||
{
|
||||
return get_rounded_size
|
||||
( size_type(sizeof(Header))
|
||||
, size_type(::boost::container::container_detail::alignment_of<block_header<size_type> >::value))
|
||||
, size_type(::boost::container::dtl::alignment_of<block_header<size_type> >::value))
|
||||
+ total_size();
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ struct block_header
|
||||
|
||||
template<class T>
|
||||
static block_header<size_type> *block_header_from_value(T *value)
|
||||
{ return block_header_from_value(value, sizeof(T), ::boost::container::container_detail::alignment_of<T>::value); }
|
||||
{ return block_header_from_value(value, sizeof(T), ::boost::container::dtl::alignment_of<T>::value); }
|
||||
|
||||
static block_header<size_type> *block_header_from_value(const void *value, std::size_t sz, std::size_t algn)
|
||||
{
|
||||
@@ -190,7 +190,7 @@ struct block_header
|
||||
block_header<size_type> * hdr =
|
||||
reinterpret_cast<block_header<size_type>*>(reinterpret_cast<char*>(header) +
|
||||
get_rounded_size( size_type(sizeof(Header))
|
||||
, size_type(::boost::container::container_detail::alignment_of<block_header<size_type> >::value)));
|
||||
, size_type(::boost::container::dtl::alignment_of<block_header<size_type> >::value)));
|
||||
//Some sanity checks
|
||||
return hdr;
|
||||
}
|
||||
@@ -201,7 +201,7 @@ struct block_header
|
||||
Header * hdr =
|
||||
reinterpret_cast<Header*>(reinterpret_cast<char*>(bheader) -
|
||||
get_rounded_size( size_type(sizeof(Header))
|
||||
, size_type(::boost::container::container_detail::alignment_of<block_header<size_type> >::value)));
|
||||
, size_type(::boost::container::dtl::alignment_of<block_header<size_type> >::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<block_header<size_type> >::value };
|
||||
enum { BlockHdrAlignment = ::boost::container::dtl::alignment_of<block_header<size_type> >::value };
|
||||
|
||||
block_header<size_type> *get_block_header() const
|
||||
{
|
||||
|
||||
@@ -27,170 +27,14 @@
|
||||
|
||||
// interprocess
|
||||
#include <boost/interprocess/interprocess_fwd.hpp>
|
||||
// interprocess/detail
|
||||
#include <boost/interprocess/detail/type_traits.hpp>
|
||||
// move/detail
|
||||
#include <boost/container/detail/iterator.hpp>
|
||||
// container/detail
|
||||
#include <boost/container/detail/transform_iterator.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace interprocess {
|
||||
|
||||
template <class PseudoReference>
|
||||
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 <class T>
|
||||
struct operator_arrow_proxy<T&>
|
||||
{
|
||||
operator_arrow_proxy(T &px)
|
||||
: m_value(px)
|
||||
{}
|
||||
|
||||
T* operator->() const { return const_cast<T*>(&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 Iterator, class UnaryFunction>
|
||||
class transform_iterator
|
||||
: public UnaryFunction
|
||||
{
|
||||
public:
|
||||
typedef typename ::boost::container::iterator_traits<Iterator>::iterator_category iterator_category;
|
||||
typedef typename ipcdetail::remove_reference<typename UnaryFunction::result_type>::type value_type;
|
||||
typedef typename ::boost::container::iterator_traits<Iterator>::difference_type difference_type;
|
||||
typedef operator_arrow_proxy<typename UnaryFunction::result_type> 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<typename UnaryFunction::result_type>
|
||||
operator->() const
|
||||
{ return operator_arrow_proxy<typename UnaryFunction::result_type>(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 <class Iterator, class UnaryFunc>
|
||||
transform_iterator<Iterator, UnaryFunc>
|
||||
make_transform_iterator(Iterator it, UnaryFunc fun)
|
||||
{
|
||||
return transform_iterator<Iterator, UnaryFunc>(it, fun);
|
||||
}
|
||||
using boost::container::make_transform_iterator;
|
||||
using boost::container::transform_iterator;
|
||||
|
||||
} //namespace interprocess {
|
||||
} //namespace boost {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ class message_queue_t
|
||||
pointer_traits<void_pointer>::template
|
||||
rebind_pointer<char>::type char_ptr;
|
||||
typedef typename boost::intrusive::pointer_traits<char_ptr>::difference_type difference_type;
|
||||
typedef typename boost::container::container_detail::make_unsigned<difference_type>::type size_type;
|
||||
typedef typename boost::container::dtl::make_unsigned<difference_type>::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<void_pointer>::template
|
||||
rebind_pointer<char>::type char_ptr;
|
||||
typedef typename boost::intrusive::pointer_traits<char_ptr>::difference_type difference_type;
|
||||
typedef typename boost::container::container_detail::make_unsigned<difference_type>::type size_type;
|
||||
typedef typename boost::container::dtl::make_unsigned<difference_type>::type size_type;
|
||||
|
||||
public:
|
||||
size_type len; // Message length
|
||||
@@ -297,7 +297,7 @@ class mq_hdr_t
|
||||
typedef typename boost::intrusive::pointer_traits
|
||||
<msg_hdr_ptr_t>::difference_type difference_type;
|
||||
typedef typename boost::container::
|
||||
container_detail::make_unsigned<difference_type>::type size_type;
|
||||
dtl::make_unsigned<difference_type>::type size_type;
|
||||
typedef typename boost::intrusive::
|
||||
pointer_traits<void_pointer>::template
|
||||
rebind_pointer<msg_hdr_ptr_t>::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<msg_header>::value,
|
||||
index_align = ::boost::container::container_detail::alignment_of<msg_hdr_ptr_t>::value,
|
||||
msg_hdr_align = ::boost::container::dtl::alignment_of<msg_header>::value,
|
||||
index_align = ::boost::container::dtl::alignment_of<msg_hdr_ptr_t>::value,
|
||||
r_hdr_size = ipcdetail::ct_rounded_size<sizeof(mq_hdr_t), index_align>::value,
|
||||
r_index_size = ipcdetail::get_rounded_size<size_type>(max_num_msg*sizeof(msg_hdr_ptr_t), msg_hdr_align),
|
||||
r_max_msg_size = ipcdetail::get_rounded_size<size_type>(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<msg_header>::value,
|
||||
index_align = ::boost::container::container_detail::alignment_of<msg_hdr_ptr_t>::value,
|
||||
msg_hdr_align = ::boost::container::dtl::alignment_of<msg_header>::value,
|
||||
index_align = ::boost::container::dtl::alignment_of<msg_hdr_ptr_t>::value,
|
||||
r_hdr_size = ipcdetail::ct_rounded_size<sizeof(mq_hdr_t), index_align>::value,
|
||||
r_index_size = ipcdetail::get_rounded_size<size_type>(m_max_num_msg*sizeof(msg_hdr_ptr_t), msg_hdr_align),
|
||||
r_max_msg_size = ipcdetail::get_rounded_size<size_type>(m_max_msg_size, msg_hdr_align) + sizeof(msg_header);
|
||||
@@ -603,7 +603,7 @@ class msg_queue_initialization_func_t
|
||||
rebind_pointer<char>::type char_ptr;
|
||||
typedef typename boost::intrusive::pointer_traits<char_ptr>::
|
||||
difference_type difference_type;
|
||||
typedef typename boost::container::container_detail::
|
||||
typedef typename boost::container::dtl::
|
||||
make_unsigned<difference_type>::type size_type;
|
||||
|
||||
msg_queue_initialization_func_t(size_type maxmsg = 0,
|
||||
|
||||
@@ -48,11 +48,11 @@ namespace ipcdetail {
|
||||
|
||||
template<class VoidPointer>
|
||||
class basic_multiallocation_chain
|
||||
: public boost::container::container_detail::
|
||||
: public boost::container::dtl::
|
||||
basic_multiallocation_chain<VoidPointer>
|
||||
{
|
||||
BOOST_MOVABLE_BUT_NOT_COPYABLE(basic_multiallocation_chain)
|
||||
typedef boost::container::container_detail::
|
||||
typedef boost::container::dtl::
|
||||
basic_multiallocation_chain<VoidPointer> base_t;
|
||||
public:
|
||||
|
||||
|
||||
@@ -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<VoidPointer> multiallocation_chain;
|
||||
|
||||
typedef typename boost::intrusive::pointer_traits<char_ptr>::difference_type difference_type;
|
||||
typedef typename boost::container::container_detail::make_unsigned<difference_type>::type size_type;
|
||||
typedef typename boost::container::dtl::make_unsigned<difference_type>::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<sizeof(block_ctrl), Alignment>::value;
|
||||
static const size_type BlockCtrlUnits = BlockCtrlBytes/Alignment;
|
||||
@@ -590,7 +590,7 @@ inline T* simple_seq_fit_impl<MutexFamily, VoidPointer>::
|
||||
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<T>::value));
|
||||
BOOST_ASSERT(0 == ((std::size_t)ret % ::boost::container::dtl::alignment_of<T>::value));
|
||||
reuse_ptr = static_cast<T*>(raw_reuse);
|
||||
return static_cast<T*>(ret);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class rbtree_best_fit
|
||||
typedef ipcdetail::basic_multiallocation_chain<VoidPointer> multiallocation_chain;
|
||||
|
||||
typedef typename boost::intrusive::pointer_traits<char_ptr>::difference_type difference_type;
|
||||
typedef typename boost::container::container_detail::make_unsigned<difference_type>::type size_type;
|
||||
typedef typename boost::container::dtl::make_unsigned<difference_type>::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<void_pointer>::value));
|
||||
BOOST_STATIC_ASSERT((Alignment >= ::boost::container::dtl::alignment_of<void_pointer>::value));
|
||||
static const size_type AlignmentMask = (Alignment - 1);
|
||||
static const size_type BlockCtrlBytes = ipcdetail::ct_rounded_size<sizeof(block_ctrl), Alignment>::value;
|
||||
static const size_type BlockCtrlUnits = BlockCtrlBytes/Alignment;
|
||||
@@ -692,7 +692,7 @@ inline T* rbtree_best_fit<MutexFamily, VoidPointer, MemAlignment>::
|
||||
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<T*>(raw_reuse);
|
||||
BOOST_ASSERT(0 == ((std::size_t)ret % ::boost::container::container_detail::alignment_of<T>::value));
|
||||
BOOST_ASSERT(0 == ((std::size_t)ret % ::boost::container::dtl::alignment_of<T>::value));
|
||||
return static_cast<T*>(ret);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
102
include/boost/interprocess/smart_ptr/intrusive_ptr.hpp
Normal file → Executable file
102
include/boost/interprocess/smart_ptr/intrusive_ptr.hpp
Normal file → Executable file
@@ -32,6 +32,7 @@
|
||||
#include <boost/interprocess/detail/utilities.hpp>
|
||||
#include <boost/intrusive/pointer_traits.hpp>
|
||||
#include <boost/move/adl_move_swap.hpp>
|
||||
#include <boost/move/core.hpp>
|
||||
|
||||
#include <iosfwd> // for std::basic_ostream
|
||||
|
||||
@@ -48,8 +49,8 @@ namespace interprocess {
|
||||
//!intrusive_ptr<T, offset_ptr<void> > defines a class with a offset_ptr<T> 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<class U> intrusive_ptr
|
||||
(intrusive_ptr<U, VP> const & rhs)
|
||||
template<class U> intrusive_ptr(intrusive_ptr<U, VP> 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<class U> intrusive_ptr & operator=
|
||||
(intrusive_ptr<U, VP> const & rhs)
|
||||
template<class U> intrusive_ptr & operator=(intrusive_ptr<U, VP> 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<class T, class U, class VP> inline
|
||||
bool operator==(intrusive_ptr<T, VP> const & a,
|
||||
intrusive_ptr<U, VP> const & b)
|
||||
intrusive_ptr<U, VP> const & b) BOOST_NOEXCEPT
|
||||
{ return a.get() == b.get(); }
|
||||
|
||||
//!Returns a.get() != b.get().
|
||||
//!Does not throw
|
||||
template<class T, class U, class VP> inline
|
||||
bool operator!=(intrusive_ptr<T, VP> const & a,
|
||||
intrusive_ptr<U, VP> const & b)
|
||||
intrusive_ptr<U, VP> const & b) BOOST_NOEXCEPT
|
||||
{ return a.get() != b.get(); }
|
||||
|
||||
//!Returns a.get() == b.
|
||||
//!Does not throw
|
||||
template<class T, class VP> inline
|
||||
bool operator==(intrusive_ptr<T, VP> const & a,
|
||||
const typename intrusive_ptr<T, VP>::pointer &b)
|
||||
const typename intrusive_ptr<T, VP>::pointer &b) BOOST_NOEXCEPT
|
||||
{ return a.get() == b; }
|
||||
|
||||
//!Returns a.get() != b.
|
||||
//!Does not throw
|
||||
template<class T, class VP> inline
|
||||
bool operator!=(intrusive_ptr<T, VP> const & a,
|
||||
const typename intrusive_ptr<T, VP>::pointer &b)
|
||||
const typename intrusive_ptr<T, VP>::pointer &b) BOOST_NOEXCEPT
|
||||
{ return a.get() != b; }
|
||||
|
||||
//!Returns a == b.get().
|
||||
//!Does not throw
|
||||
template<class T, class VP> inline
|
||||
bool operator==(const typename intrusive_ptr<T, VP>::pointer &a,
|
||||
intrusive_ptr<T, VP> const & b)
|
||||
intrusive_ptr<T, VP> const & b) BOOST_NOEXCEPT
|
||||
{ return a == b.get(); }
|
||||
|
||||
//!Returns a != b.get().
|
||||
//!Does not throw
|
||||
template<class T, class VP> inline
|
||||
bool operator!=(const typename intrusive_ptr<T, VP>::pointer &a,
|
||||
intrusive_ptr<T, VP> const & b)
|
||||
intrusive_ptr<T, VP> const & b) BOOST_NOEXCEPT
|
||||
{ return a != b.get(); }
|
||||
|
||||
//!Returns a.get() < b.get().
|
||||
//!Does not throw
|
||||
template<class T, class VP> inline
|
||||
bool operator<(intrusive_ptr<T, VP> const & a,
|
||||
intrusive_ptr<T, VP> const & b)
|
||||
intrusive_ptr<T, VP> const & b) BOOST_NOEXCEPT
|
||||
{
|
||||
return std::less<typename intrusive_ptr<T, VP>::pointer>()
|
||||
(a.get(), b.get());
|
||||
@@ -237,34 +265,34 @@ bool operator<(intrusive_ptr<T, VP> const & a,
|
||||
//!Does not throw
|
||||
template<class T, class VP> inline
|
||||
void swap(intrusive_ptr<T, VP> & lhs,
|
||||
intrusive_ptr<T, VP> & rhs)
|
||||
intrusive_ptr<T, VP> & rhs) BOOST_NOEXCEPT
|
||||
{ lhs.swap(rhs); }
|
||||
|
||||
// operator<<
|
||||
template<class E, class T, class Y, class VP>
|
||||
inline std::basic_ostream<E, T> & operator<<
|
||||
(std::basic_ostream<E, T> & os, intrusive_ptr<Y, VP> const & p)
|
||||
(std::basic_ostream<E, T> & os, intrusive_ptr<Y, VP> const & p) BOOST_NOEXCEPT
|
||||
{ os << p.get(); return os; }
|
||||
|
||||
//!Returns p.get().
|
||||
//!Does not throw
|
||||
template<class T, class VP>
|
||||
inline typename boost::interprocess::intrusive_ptr<T, VP>::pointer
|
||||
to_raw_pointer(intrusive_ptr<T, VP> p)
|
||||
to_raw_pointer(intrusive_ptr<T, VP> p) BOOST_NOEXCEPT
|
||||
{ return p.get(); }
|
||||
|
||||
/*Emulates static cast operator. Does not throw*/
|
||||
/*
|
||||
template<class T, class U, class VP>
|
||||
inline boost::interprocess::intrusive_ptr<T, VP> static_pointer_cast
|
||||
(boost::interprocess::intrusive_ptr<U, VP> const & p)
|
||||
(boost::interprocess::intrusive_ptr<U, VP> const & p) BOOST_NOEXCEPT
|
||||
{ return do_static_cast<U>(p.get()); }
|
||||
*/
|
||||
/*Emulates const cast operator. Does not throw*/
|
||||
/*
|
||||
template<class T, class U, class VP>
|
||||
inline boost::interprocess::intrusive_ptr<T, VP> const_pointer_cast
|
||||
(boost::interprocess::intrusive_ptr<U, VP> const & p)
|
||||
(boost::interprocess::intrusive_ptr<U, VP> const & p) BOOST_NOEXCEPT
|
||||
{ return do_const_cast<U>(p.get()); }
|
||||
*/
|
||||
|
||||
@@ -272,7 +300,7 @@ inline boost::interprocess::intrusive_ptr<T, VP> const_pointer_cast
|
||||
/*
|
||||
template<class T, class U, class VP>
|
||||
inline boost::interprocess::intrusive_ptr<T, VP> dynamic_pointer_cast
|
||||
(boost::interprocess::intrusive_ptr<U, VP> const & p)
|
||||
(boost::interprocess::intrusive_ptr<U, VP> const & p) BOOST_NOEXCEPT
|
||||
{ return do_dynamic_cast<U>(p.get()); }
|
||||
*/
|
||||
|
||||
@@ -280,7 +308,7 @@ inline boost::interprocess::intrusive_ptr<T, VP> dynamic_pointer_cast
|
||||
/*
|
||||
template<class T, class U, class VP>
|
||||
inline boost::interprocess::intrusive_ptr<T, VP>reinterpret_pointer_cast
|
||||
(boost::interprocess::intrusive_ptr<U, VP> const & p)
|
||||
(boost::interprocess::intrusive_ptr<U, VP> const & p) BOOST_NOEXCEPT
|
||||
{ return do_reinterpret_cast<U>(p.get()); }
|
||||
*/
|
||||
|
||||
@@ -292,7 +320,7 @@ inline boost::interprocess::intrusive_ptr<T, VP>reinterpret_pointer_cast
|
||||
//!Returns p.get().
|
||||
//!Does not throw
|
||||
template<class T, class VP>
|
||||
inline T *to_raw_pointer(boost::interprocess::intrusive_ptr<T, VP> p)
|
||||
inline T *to_raw_pointer(boost::interprocess::intrusive_ptr<T, VP> p) BOOST_NOEXCEPT
|
||||
{ return p.get(); }
|
||||
#endif
|
||||
|
||||
|
||||
@@ -72,6 +72,49 @@ void try_based_lock(MutexType &m)
|
||||
}
|
||||
}
|
||||
|
||||
template<class MutexType>
|
||||
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<class MutexType>
|
||||
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
|
||||
|
||||
@@ -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
|
||||
<!boost::container::container_detail::is_pair<T1>::value &&
|
||||
!boost::container::container_detail::is_pair<T2>::value
|
||||
, typename boost::container::dtl::enable_if_c
|
||||
<!boost::container::dtl::is_pair<T1>::value &&
|
||||
!boost::container::dtl::is_pair<T2>::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
|
||||
<boost::container::container_detail::is_pair<Pair1>::value &&
|
||||
boost::container::container_detail::is_pair<Pair2>::value
|
||||
, typename boost::container::dtl::enable_if_c
|
||||
<boost::container::dtl::is_pair<Pair1>::value &&
|
||||
boost::container::dtl::is_pair<Pair2>::value
|
||||
>::type* = 0)
|
||||
{
|
||||
return CheckEqual(pair1.first, pair2.first) && CheckEqual(pair1.second, pair2.second);
|
||||
|
||||
@@ -142,7 +142,7 @@ bool test_expected_container(const Container &ec, const std::pair<EmplaceInt, Em
|
||||
static EmplaceInt expected [10];
|
||||
|
||||
typedef std::pair<EmplaceInt, EmplaceInt> EmplaceIntPair;
|
||||
static boost::container::container_detail::aligned_storage<sizeof(EmplaceIntPair)*10>::type pair_storage;
|
||||
static boost::container::dtl::aligned_storage<sizeof(EmplaceIntPair)*10>::type pair_storage;
|
||||
|
||||
static EmplaceIntPair* initialize_emplace_int_pair()
|
||||
{
|
||||
|
||||
@@ -17,10 +17,15 @@
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/move/adl_move_swap.hpp>
|
||||
#include <boost/move/core.hpp>
|
||||
#include <functional>
|
||||
|
||||
typedef boost::interprocess::offset_ptr<void> 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<X, VP> px(x);
|
||||
BOOST_TEST(addref_release_calls == prev_addref_release_calls + 1);
|
||||
|
||||
//static_assert(std::is_nothrow_move_constructible< boost::interprocess::intrusive_ptr<X, VP> >::value, "test instrusive_ptr is nothrow move constructible");
|
||||
|
||||
boost::interprocess::intrusive_ptr<X, VP> 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<X, VP> 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<X, VP> >::value, "test if nothrow move assignable ");
|
||||
|
||||
boost::interprocess::intrusive_ptr<X, VP> 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
|
||||
|
||||
@@ -69,7 +69,7 @@ int test_rbtree_best_fit()
|
||||
|
||||
int main ()
|
||||
{
|
||||
const std::size_t void_ptr_align = ::boost::container::container_detail::alignment_of<offset_ptr<void> >::value;
|
||||
const std::size_t void_ptr_align = ::boost::container::dtl::alignment_of<offset_ptr<void> >::value;
|
||||
|
||||
if(test_simple_seq_fit()){
|
||||
return 1;
|
||||
|
||||
@@ -48,10 +48,9 @@ class derived_class
|
||||
|
||||
int simple_test()
|
||||
{
|
||||
typedef allocator<base_class, managed_shared_memory::segment_manager>
|
||||
base_class_allocator;
|
||||
typedef deleter<base_class, managed_shared_memory::segment_manager>
|
||||
base_deleter_t;
|
||||
typedef managed_shared_memory::segment_manager segment_mngr_t;
|
||||
typedef allocator<base_class, segment_mngr_t> base_class_allocator;
|
||||
typedef deleter<base_class, segment_mngr_t> base_deleter_t;
|
||||
typedef shared_ptr<base_class, base_class_allocator, base_deleter_t> 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, managed_shared_memory::segment_manager >
|
||||
char_allocator_t;
|
||||
typedef allocator<char, segment_mngr_t> char_allocator_t;
|
||||
|
||||
//A shared memory string class
|
||||
typedef basic_string<char, std::char_traits<char>,
|
||||
char_allocator_t> string_t;
|
||||
typedef basic_string<char, std::char_traits<char>, char_allocator_t> string_t;
|
||||
|
||||
//A shared memory string allocator
|
||||
typedef allocator<string_t, managed_shared_memory::segment_manager>
|
||||
string_allocator_t;
|
||||
typedef allocator<string_t, segment_mngr_t> string_allocator_t;
|
||||
|
||||
//A deleter for shared_ptr<> that erases a shared memory string
|
||||
typedef deleter<string_t, managed_shared_memory::segment_manager>
|
||||
string_deleter_t;
|
||||
typedef deleter<string_t, segment_mngr_t> string_deleter_t;
|
||||
|
||||
//A shared pointer that points to a shared memory string and its instantiation
|
||||
typedef shared_ptr<string_t, string_allocator_t, string_deleter_t> string_shared_ptr_t;
|
||||
|
||||
//An allocator for shared pointers to a string in shared memory
|
||||
typedef allocator<string_shared_ptr_t, managed_shared_memory::segment_manager>
|
||||
string_shared_ptr_allocator_t;
|
||||
typedef allocator<string_shared_ptr_t, segment_mngr_t> string_shared_ptr_allocator_t;
|
||||
|
||||
//A weak pointer that points to a shared memory string and its instantiation
|
||||
typedef weak_ptr<string_t, string_allocator_t, string_deleter_t> string_weak_ptr_t;
|
||||
|
||||
//An allocator for weak pointers to a string in shared memory
|
||||
typedef allocator<string_weak_ptr_t, managed_shared_memory::segment_manager >
|
||||
string_weak_ptr_allocator_t;
|
||||
typedef allocator<string_weak_ptr_t, segment_mngr_t > string_weak_ptr_allocator_t;
|
||||
|
||||
//A vector of shared pointers to strings (all in shared memory) and its instantiation
|
||||
typedef vector<string_shared_ptr_t, string_shared_ptr_allocator_t>
|
||||
@@ -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<string_t, string_deleter_t> scoped_string
|
||||
(shmem.construct<string_t>(anonymous_instance)(string_allocator),
|
||||
deleter);
|
||||
(shmem.construct<string_t>(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<T, A, D> const & p)
|
||||
|
||||
int basic_shared_ptr_test()
|
||||
{
|
||||
typedef allocator<void, managed_shared_memory::segment_manager>
|
||||
v_allocator_t;
|
||||
|
||||
typedef deleter<X, managed_shared_memory::segment_manager>
|
||||
x_deleter_t;
|
||||
|
||||
typedef deleter<Y, managed_shared_memory::segment_manager>
|
||||
y_deleter_t;
|
||||
|
||||
typedef managed_shared_memory::segment_manager segment_mngr_t;
|
||||
typedef allocator<void, segment_mngr_t> v_allocator_t;
|
||||
typedef deleter<X, segment_mngr_t> x_deleter_t;
|
||||
typedef deleter<Y, segment_mngr_t> y_deleter_t;
|
||||
typedef shared_ptr<X, v_allocator_t, x_deleter_t> x_shared_ptr;
|
||||
|
||||
typedef shared_ptr<Y, v_allocator_t, y_deleter_t> y_shared_ptr;
|
||||
|
||||
typedef weak_ptr<X, v_allocator_t, x_deleter_t> x_weak_ptr;
|
||||
|
||||
typedef weak_ptr<Y, v_allocator_t, y_deleter_t> y_weak_ptr;
|
||||
|
||||
std::string process_name;
|
||||
@@ -557,11 +544,9 @@ struct alias_tester
|
||||
|
||||
void test_alias()
|
||||
{
|
||||
typedef allocator<void, managed_shared_memory::segment_manager>
|
||||
v_allocator_t;
|
||||
|
||||
typedef deleter<int, managed_shared_memory::segment_manager>
|
||||
int_deleter_t;
|
||||
typedef managed_shared_memory::segment_manager segment_mngr_t;
|
||||
typedef allocator<void, segment_mngr_t> v_allocator_t;
|
||||
typedef deleter<int, segment_mngr_t> int_deleter_t;
|
||||
|
||||
typedef shared_ptr<int, v_allocator_t, int_deleter_t> int_shared_ptr;
|
||||
typedef shared_ptr<const int, v_allocator_t, int_deleter_t> const_int_shared_ptr;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user