diff --git a/doc/smart_ptr/atomic_shared_ptr.adoc b/doc/smart_ptr/atomic_shared_ptr.adoc index 1072b4f..43c0f85 100644 --- a/doc/smart_ptr/atomic_shared_ptr.adoc +++ b/doc/smart_ptr/atomic_shared_ptr.adoc @@ -16,7 +16,8 @@ http://www.boost.org/LICENSE_1_0.txt ## Description The class template `atomic_shared_ptr` implements the interface of `std::atomic` -for a contained value of type `shared_ptr`. +for a contained value of type `shared_ptr`. Concurrent access to `atomic_shared_ptr` +is not a data race. ## Synopsis @@ -86,7 +87,7 @@ atomic_shared_ptr& operator=( shared_ptr r ) noexcept; [none] * {blank} + -Effects:: `atomic_store( &p_, r )`. +Effects:: `p_.swap(r)`. Returns:: `*this`. ``` @@ -97,6 +98,8 @@ bool is_lock_free() const noexcept; + Returns:: `false`. +NOTE: This implementation is not lock-free. + ``` shared_ptr load( int = 0 ) const noexcept; ``` @@ -106,9 +109,10 @@ operator shared_ptr() const noexcept; [none] * {blank} + -Returns:: `atomic_load( &p_ )`. +Returns:: `p_`. -NOTE: The `int` argument is intended to be of type `memory_order`, but is ignored in this implementation. +NOTE: The `int` argument is intended to be of type `memory_order`, but is ignored. + This implementation is lock-based and therefore always sequentially consistent. ``` void store( shared_ptr r, int = 0 ) noexcept; @@ -116,7 +120,7 @@ void store( shared_ptr r, int = 0 ) noexcept; [none] * {blank} + -Effects:: `atomic_store( &p_, r )`. +Effects:: `p_.swap(r)`. ``` shared_ptr exchange( shared_ptr r, int = 0 ) noexcept; @@ -124,7 +128,8 @@ shared_ptr exchange( shared_ptr r, int = 0 ) noexcept; [none] * {blank} + -Returns:: `atomic_exchange( &p_, r )`. +Effects:: `p_.swap(r)`. +Returns:: The old value of `p_`. ``` bool compare_exchange_weak( shared_ptr& v, const shared_ptr& w, int, int ) noexcept; @@ -141,7 +146,9 @@ bool compare_exchange_strong( shared_ptr& v, const shared_ptr& w, int = 0 [none] * {blank} + -Returns:: `atomic_compare_exchange( &p_, &v, w )`. +Effects:: If `p_` is equivalent to `v`, assigns `w` to `p_`, otherwise assigns `p_` to `v`. +Returns:: `true` if `p_` was equivalent to `v`, `false` otherwise. +Remarks:: Two `shared_ptr` instances are equivalent if they store the same pointer value and _share ownership_. ``` bool compare_exchange_weak( shared_ptr& v, shared_ptr&& w, int, int ) noexcept; @@ -158,5 +165,6 @@ bool compare_exchange_strong( shared_ptr& v, shared_ptr&& w, int = 0 ) noe [none] * {blank} + -Returns:: `atomic_compare_exchange( &p_, &v, std::move( w ) )`. - +Effects:: If `p_` is equivalent to `v`, assigns `std::move(w)` to `p_`, otherwise assigns `p_` to `v`. +Returns:: `true` if `p_` was equivalent to `v`, `false` otherwise. +Remarks:: The old value of `w` is not preserved in either case.