mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-07-31 21:24:40 +02:00
Update specification of atomic_shared_ptr
This commit is contained in:
@@ -16,7 +16,8 @@ http://www.boost.org/LICENSE_1_0.txt
|
||||
## Description
|
||||
|
||||
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
|
||||
|
||||
@@ -86,7 +87,7 @@ atomic_shared_ptr& operator=( shared_ptr<T> 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<T> load( int = 0 ) const noexcept;
|
||||
```
|
||||
@@ -106,9 +109,10 @@ operator shared_ptr<T>() 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<T> r, int = 0 ) noexcept;
|
||||
@@ -116,7 +120,7 @@ void store( shared_ptr<T> r, int = 0 ) noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: `atomic_store( &p_, r )`.
|
||||
Effects:: `p_.swap(r)`.
|
||||
|
||||
```
|
||||
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]
|
||||
* {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;
|
||||
@@ -141,7 +146,9 @@ bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& 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<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]
|
||||
* {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.
|
||||
|
Reference in New Issue
Block a user