std::atomic_is_lock_free<std::shared_ptr>, std::atomic_load<std::shared_ptr>, std::atomic_store<std::shared_ptr>, std::atomic_...<std::shared_ptr>
Template:ddcl list begin <tr class="t-dcl ">
<td >bool atomic_is_lock_free( const std::shared_ptr<T>* p );
<td > (1) </td> <td > (since C++11) </td> </tr> <tr class="t-dcl ">
<td >std::shared_ptr<T> atomic_load( const std::shared_ptr<T>* p );
<td > (2) </td> <td > (since C++11) </td> </tr> <tr class="t-dcl ">
<td >std::shared_ptr<T> atomic_load_explicit( const shared_ptr<T>* p,
<td > (3) </td> <td > (since C++11) </td> </tr> <tr class="t-dcl ">
<td >void atomic_store( std::shared_ptr<T>* p,
<td > (4) </td> <td > (since C++11) </td> </tr> <tr class="t-dcl ">
<td >void atomic_store_explicit( std::shared_ptr<T>* p,
shared_ptr<T> r,
<td > (5) </td> <td > (since C++11) </td> </tr> <tr class="t-dcl ">
<td >std::shared_ptr<T> atomic_exchange( std::shared_ptr<T>* p,
<td > (6) </td> <td > (since C++11) </td> </tr> <tr class="t-dcl ">
<td >std::shared_ptr<T> atomic_exchange_explicit( std::shared_ptr<T>* p,
std::shared_ptr<T> r,
<td > (7) </td> <td > (since C++11) </td> </tr> <tr class="t-dcl ">
<td >bool atomic_compare_exchange_weak( std::shared_ptr<T>* p,
std::shared_ptr<T>* expected,
<td > (8) </td> <td > (since C++11) </td> </tr> <tr class="t-dcl ">
<td >bool atomic_compare_exchange_strong( std::shared_ptr<T>* p,
std::shared_ptr<T>* expected,
<td > (9) </td> <td > (since C++11) </td> </tr> <tr class="t-dcl ">
<td >bool atomic_compare_exchange_strong_explicit( std::shared_ptr<T>* p,
std::shared_ptr<T>* expected,
std::shared_ptr<T> desired,
std::memory_order success,
<td > (10) </td> <td > (since C++11) </td> </tr> <tr class="t-dcl ">
<td >bool atomic_compare_exchange_weak_explicit( std::shared_ptr<T>* p,
std::shared_ptr<T>* expected,
std::shared_ptr<T> desired,
std::memory_order success,
<td > (11) </td> <td > (since C++11) </td> </tr> Template:ddcl list end
If multiple threads of execution access the object referenced by the same std::shared_ptr simultaneously, a data race occurs, unless all such access is performed through these functions, which are partial specializations of the corresponding atomic access functions (std::atomic_load, std::atomic_store, etc)
Note that the control block of a shared_ptr is thread-safe: different std::shared_ptr objects can be accessed using mutable operations, such as operator= or reset, simultaneously by multiple threads, even when these instances are copies, and share the same control block internally.
p
is lock-free.p
. As with the non-specialized std::atomic_load_explicit, mo
cannot be std::memory_order_release or std::memory_order_acq_relp
and r
, effectively executing p->swap(r). As with the non-specialized std::atomic_store_explicit, mo
cannot be std::memory_order_acquire or std::memory_order_acq_relp
and r
, effectively executing p->swap(r) and returns a copy of the shared pointer formerly pointed-to by p
p
and expected
. If they are equivalent (share ownership of the same pointer and refer to the same pointer), assigns desired
into *p
using the memory ordering constraints specified by success
and returns true. If they are not equivalent, assigns *p
into *expected
using the memory ordering constraints specified by failure
and returns false.All these functions invoke undefined behavior if p
is a null pointer.
Contents |
Parameters
p, expected | - | a pointer to a std::shared_ptr |
r, desired | - | a std::shared_ptr |
mo, success, failure | - | memory ordering selectors of type std::memory_order |
Exceptions
These functions do not throw exceptions.