diff options
Diffstat (limited to 'boost/smart_ptr')
-rw-r--r-- | boost/smart_ptr/allocate_shared_array.hpp | 10 | ||||
-rw-r--r-- | boost/smart_ptr/atomic_shared_ptr.hpp | 72 | ||||
-rw-r--r-- | boost/smart_ptr/detail/sp_counted_base_clang.hpp | 4 | ||||
-rw-r--r-- | boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp | 6 | ||||
-rw-r--r-- | boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp | 4 | ||||
-rw-r--r-- | boost/smart_ptr/local_shared_ptr.hpp | 4 | ||||
-rw-r--r-- | boost/smart_ptr/shared_ptr.hpp | 8 |
7 files changed, 82 insertions, 26 deletions
diff --git a/boost/smart_ptr/allocate_shared_array.hpp b/boost/smart_ptr/allocate_shared_array.hpp index 53023e7182..340688146c 100644 --- a/boost/smart_ptr/allocate_shared_array.hpp +++ b/boost/smart_ptr/allocate_shared_array.hpp @@ -353,9 +353,9 @@ public: typedef A type; template<class U> - sp_array_state(const U& allocator, std::size_t size) BOOST_SP_NOEXCEPT - : allocator_(allocator), - size_(size) { } + sp_array_state(const U& _allocator, std::size_t _size) BOOST_SP_NOEXCEPT + : allocator_(_allocator), + size_(_size) { } A& allocator() BOOST_SP_NOEXCEPT { return allocator_; @@ -376,8 +376,8 @@ public: typedef A type; template<class U> - sp_size_array_state(const U& allocator, std::size_t) BOOST_SP_NOEXCEPT - : allocator_(allocator) { } + sp_size_array_state(const U& _allocator, std::size_t) BOOST_SP_NOEXCEPT + : allocator_(_allocator) { } A& allocator() BOOST_SP_NOEXCEPT { return allocator_; diff --git a/boost/smart_ptr/atomic_shared_ptr.hpp b/boost/smart_ptr/atomic_shared_ptr.hpp index d1efa8e280..7c485070f8 100644 --- a/boost/smart_ptr/atomic_shared_ptr.hpp +++ b/boost/smart_ptr/atomic_shared_ptr.hpp @@ -97,7 +97,13 @@ public: return false; } - shared_ptr<T> load( int = 0 ) const BOOST_SP_NOEXCEPT + shared_ptr<T> load() const BOOST_SP_NOEXCEPT + { + boost::detail::spinlock::scoped_lock lock( l_ ); + return p_; + } + + template<class M> shared_ptr<T> load( M ) const BOOST_SP_NOEXCEPT { boost::detail::spinlock::scoped_lock lock( l_ ); return p_; @@ -109,13 +115,19 @@ public: return p_; } - void store( shared_ptr<T> r, int = 0 ) BOOST_SP_NOEXCEPT + void store( shared_ptr<T> r ) BOOST_SP_NOEXCEPT { boost::detail::spinlock::scoped_lock lock( l_ ); p_.swap( r ); } - shared_ptr<T> exchange( shared_ptr<T> r, int = 0 ) BOOST_SP_NOEXCEPT + template<class M> void store( shared_ptr<T> r, M ) BOOST_SP_NOEXCEPT + { + boost::detail::spinlock::scoped_lock lock( l_ ); + p_.swap( r ); + } + + shared_ptr<T> exchange( shared_ptr<T> r ) BOOST_SP_NOEXCEPT { { boost::detail::spinlock::scoped_lock lock( l_ ); @@ -133,44 +145,82 @@ public: #endif } - bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, int, int ) BOOST_SP_NOEXCEPT + template<class M> shared_ptr<T> exchange( shared_ptr<T> r, M ) BOOST_SP_NOEXCEPT + { + { + boost::detail::spinlock::scoped_lock lock( l_ ); + p_.swap( r ); + } + +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + + return std::move( r ); + +#else + + return r; + +#endif + } + + template<class M> bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, M, M ) BOOST_SP_NOEXCEPT { return compare_exchange( v, w ); } - bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, int = 0 ) BOOST_SP_NOEXCEPT + template<class M> bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, M ) BOOST_SP_NOEXCEPT { return compare_exchange( v, w ); } - bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, int, int ) BOOST_SP_NOEXCEPT + bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w ) BOOST_SP_NOEXCEPT { return compare_exchange( v, w ); } - bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, int = 0 ) BOOST_SP_NOEXCEPT + template<class M> bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, M, M ) BOOST_SP_NOEXCEPT + { + return compare_exchange( v, w ); + } + + template<class M> bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, M ) BOOST_SP_NOEXCEPT + { + return compare_exchange( v, w ); + } + + bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w ) BOOST_SP_NOEXCEPT { return compare_exchange( v, w ); } #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) - bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, int, int ) BOOST_SP_NOEXCEPT + template<class M> bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, M, M ) BOOST_SP_NOEXCEPT + { + return compare_exchange( v, std::move( w ) ); + } + + template<class M> bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, M ) BOOST_SP_NOEXCEPT + { + return compare_exchange( v, std::move( w ) ); + } + + bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w ) BOOST_SP_NOEXCEPT { return compare_exchange( v, std::move( w ) ); } - bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, int = 0 ) BOOST_SP_NOEXCEPT + template<class M> bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, M, M ) BOOST_SP_NOEXCEPT { return compare_exchange( v, std::move( w ) ); } - bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, int, int ) BOOST_SP_NOEXCEPT + template<class M> bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, M ) BOOST_SP_NOEXCEPT { return compare_exchange( v, std::move( w ) ); } - bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, int = 0 ) BOOST_SP_NOEXCEPT + bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w ) BOOST_SP_NOEXCEPT { return compare_exchange( v, std::move( w ) ); } diff --git a/boost/smart_ptr/detail/sp_counted_base_clang.hpp b/boost/smart_ptr/detail/sp_counted_base_clang.hpp index 8b3bfad9b6..5d6e073d95 100644 --- a/boost/smart_ptr/detail/sp_counted_base_clang.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_clang.hpp @@ -70,8 +70,8 @@ private: sp_counted_base( sp_counted_base const & ); sp_counted_base & operator= ( sp_counted_base const & ); - atomic_int_least32_t use_count_; // #shared - atomic_int_least32_t weak_count_; // #weak + (#shared != 0) + atomic_int_least32_t use_count_; // #shared + atomic_int_least32_t weak_count_; // #weak + (#shared != 0) public: diff --git a/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp b/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp index 76ac2a612d..c3175cf8ed 100644 --- a/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp @@ -38,7 +38,9 @@ inline void atomic_increment( int * pw ) ( "0:\n\t" ".set push\n\t" +#if !defined(__mips_isa_rev) || (__mips_isa_rev < 6) ".set mips2\n\t" +#endif "ll %0, %1\n\t" "addiu %0, 1\n\t" "sc %0, %1\n\t" @@ -59,7 +61,9 @@ inline int atomic_decrement( int * pw ) ( "0:\n\t" ".set push\n\t" +#if !defined(__mips_isa_rev) || (__mips_isa_rev < 6) ".set mips2\n\t" +#endif "ll %1, %2\n\t" "addiu %0, %1, -1\n\t" "sc %0, %2\n\t" @@ -85,7 +89,9 @@ inline int atomic_conditional_increment( int * pw ) ( "0:\n\t" ".set push\n\t" +#if !defined(__mips_isa_rev) || (__mips_isa_rev < 6) ".set mips2\n\t" +#endif "ll %0, %2\n\t" "beqz %0, 1f\n\t" "addiu %1, %0, 1\n\t" diff --git a/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp b/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp index 7a188f8a66..9f562b9b4a 100644 --- a/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp +++ b/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp @@ -64,8 +64,8 @@ private: sp_counted_base( sp_counted_base const & ); sp_counted_base & operator= ( sp_counted_base const & ); - std::atomic_int_least32_t use_count_; // #shared - std::atomic_int_least32_t weak_count_; // #weak + (#shared != 0) + std::atomic_int_least32_t use_count_; // #shared + std::atomic_int_least32_t weak_count_; // #weak + (#shared != 0) public: diff --git a/boost/smart_ptr/local_shared_ptr.hpp b/boost/smart_ptr/local_shared_ptr.hpp index 0d1fa0182e..1bf1fdf174 100644 --- a/boost/smart_ptr/local_shared_ptr.hpp +++ b/boost/smart_ptr/local_shared_ptr.hpp @@ -239,9 +239,9 @@ public: template< class Y, class D > local_shared_ptr( boost::movelib::unique_ptr< Y, D > r ); // ! - // : px( r.get() ), pn( new boost::detail::local_counted_impl( shared_ptr<T>( std::move(r) ) ) ) + // : px( r.get() ), pn( new boost::detail::local_counted_impl( shared_ptr<T>( std::move(r) ) ) ) //{ - // boost::detail::sp_assert_convertible< Y, T >(); + // boost::detail::sp_assert_convertible< Y, T >(); //} // copy constructor diff --git a/boost/smart_ptr/shared_ptr.hpp b/boost/smart_ptr/shared_ptr.hpp index e8a302c74a..4ac0699ef6 100644 --- a/boost/smart_ptr/shared_ptr.hpp +++ b/boost/smart_ptr/shared_ptr.hpp @@ -1080,7 +1080,7 @@ template<class T> shared_ptr<T> atomic_load( shared_ptr<T> const * p ) BOOST_SP_ return *p; } -template<class T> inline shared_ptr<T> atomic_load_explicit( shared_ptr<T> const * p, /*memory_order mo*/ int ) BOOST_SP_NOEXCEPT +template<class T, class M> inline shared_ptr<T> atomic_load_explicit( shared_ptr<T> const * p, /*memory_order mo*/ M ) BOOST_SP_NOEXCEPT { return atomic_load( p ); } @@ -1091,7 +1091,7 @@ template<class T> void atomic_store( shared_ptr<T> * p, shared_ptr<T> r ) BOOST_ p->swap( r ); } -template<class T> inline void atomic_store_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ int ) BOOST_SP_NOEXCEPT +template<class T, class M> inline void atomic_store_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ M ) BOOST_SP_NOEXCEPT { atomic_store( p, r ); // std::move( r ) } @@ -1107,7 +1107,7 @@ template<class T> shared_ptr<T> atomic_exchange( shared_ptr<T> * p, shared_ptr<T return r; // return std::move( r ) } -template<class T> shared_ptr<T> inline atomic_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ int ) BOOST_SP_NOEXCEPT +template<class T, class M> shared_ptr<T> inline atomic_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ M ) BOOST_SP_NOEXCEPT { return atomic_exchange( p, r ); // std::move( r ) } @@ -1137,7 +1137,7 @@ template<class T> bool atomic_compare_exchange( shared_ptr<T> * p, shared_ptr<T> } } -template<class T> inline bool atomic_compare_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w, /*memory_order success*/ int, /*memory_order failure*/ int ) BOOST_SP_NOEXCEPT +template<class T, class M> inline bool atomic_compare_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w, /*memory_order success*/ M, /*memory_order failure*/ M ) BOOST_SP_NOEXCEPT { return atomic_compare_exchange( p, v, w ); // std::move( w ) } |