Update specification of atomic_shared_ptr

This commit is contained in:
Peter Dimov
2017-06-18 15:34:57 +03:00
parent 7ed8583a9c
commit 5b316e6e90

View File

@@ -16,7 +16,8 @@ http://www.boost.org/LICENSE_1_0.txt
## Description ## Description
The class template `atomic_shared_ptr<T>` implements the interface of `std::atomic` The class template `atomic_shared_ptr<T>` implements the interface of `std::atomic`
for a contained value of type `shared_ptr<T>`. for a contained value of type `shared_ptr<T>`. Concurrent access to `atomic_shared_ptr`
is not a data race.
## Synopsis ## Synopsis
@@ -86,7 +87,7 @@ atomic_shared_ptr& operator=( shared_ptr<T> r ) noexcept;
[none] [none]
* {blank} * {blank}
+ +
Effects:: `atomic_store( &p_, r )`. Effects:: `p_.swap(r)`.
Returns:: `*this`. Returns:: `*this`.
``` ```
@@ -97,6 +98,8 @@ bool is_lock_free() const noexcept;
+ +
Returns:: `false`. Returns:: `false`.
NOTE: This implementation is not lock-free.
``` ```
shared_ptr<T> load( int = 0 ) const noexcept; shared_ptr<T> load( int = 0 ) const noexcept;
``` ```
@@ -106,9 +109,10 @@ operator shared_ptr<T>() const noexcept;
[none] [none]
* {blank} * {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<T> r, int = 0 ) noexcept; void store( shared_ptr<T> r, int = 0 ) noexcept;
@@ -116,7 +120,7 @@ void store( shared_ptr<T> r, int = 0 ) noexcept;
[none] [none]
* {blank} * {blank}
+ +
Effects:: `atomic_store( &p_, r )`. Effects:: `p_.swap(r)`.
``` ```
shared_ptr<T> exchange( shared_ptr<T> r, int = 0 ) noexcept; shared_ptr<T> exchange( shared_ptr<T> r, int = 0 ) noexcept;
@@ -124,7 +128,8 @@ shared_ptr<T> exchange( shared_ptr<T> r, int = 0 ) noexcept;
[none] [none]
* {blank} * {blank}
+ +
Returns:: `atomic_exchange( &p_, r )`. Effects:: `p_.swap(r)`.
Returns:: The old value of `p_`.
``` ```
bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, int, int ) noexcept; bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, int, int ) noexcept;
@@ -141,7 +146,9 @@ bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, int = 0
[none] [none]
* {blank} * {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<T>& v, shared_ptr<T>&& w, int, int ) noexcept; bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, int, int ) noexcept;
@@ -158,5 +165,6 @@ bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, int = 0 ) noe
[none] [none]
* {blank} * {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.