std::experimental::atomic_shared_ptr<T>::compare_exchange_strong, (3) - Linux Manuals
std::experimental::atomic_shared_ptr<T>::compare_exchange_strong,: std::experimental::atomic_shared_ptr<T>::compare_exchange_strong,
NAME
std::experimental::atomic_shared_ptr<T>::compare_exchange_strong, - std::experimental::atomic_shared_ptr<T>::compare_exchange_strong,
Synopsis
bool compare_exchange_weak(
std::shared_ptr<T>&
std::memory_order success, std::memory_order failure
bool compare_exchange_weak(
desired,
std::memory_order success, std::memory_order failure
bool compare_exchange_weak(
std::shared_ptr<T>&
std::memory_order order
bool compare_exchange_weak(
desired,
std::memory_order order
bool compare_exchange_strong(
std::shared_ptr<T>&
std::memory_order success, std::memory_order failure
bool compare_exchange_strong(
std::shared_ptr<T>&&
std::memory_order success, std::memory_order failure
bool compare_exchange_strong(
std::shared_ptr<T>&
std::memory_order order
bool compare_exchange_strong(
std::shared_ptr<T>&&
std::memory_order order
Atomically compares the underlying shared_ptr in
are equivalent, replaces the former with desired
operation). Otherwise, loads the actual value stored in
(performs load operation). The replacement is performed as if by the copy or move
assignment operator of shared_ptr, as appropriate.
Two shared_ptrs are equivalent if and only if they store the same pointer value and
share ownership.
The memory models for the read-modify-write and load operations are success and
failure respectively. For overloads
read-modify-write and load operations, except that std::memory_order_acquire and
std::memory_order_relaxed are used for the load operation if order
std::memory_order_acq_rel, or order
The weak versions
Parameters
expected - reference to the value expected to be found in the atomic object
desired
success
failure
order
Return value
true if the underlying atomic value was changed, false otherwise.
All changes to the atomic_shared_ptr object itself, and all associated use_count
increments, are guaranteed to be performed atomically. Associated use_count
decrements take place after the atomic operation, but are not required to be part of
it. Any associated destruction or deallocation operations take place after the
atomic operation and are not part of it.
If the compare-exchange operation return true, expected is not accessed after the
atomic update step. If it returns false, expected is updated with the existing value
read from the atomic_shared_ptr object in the attempted atomic update. The use_count
update corresponding to the write to expected is part of the atomic operation, but
the write to expected itself is not required to be part of the atomic operation.
For overloads
For overloads
operation returns true;
Notes
The weak forms
as if
compare-and-exchange is in a loop, the weak version will yield better performance on
some platforms.
See also
std::atomic_is_lock_free(std::shared_ptr)
std::atomic_load(std::shared_ptr)
std::atomic_load_explicit(std::shared_ptr)
std::atomic_store(std::shared_ptr)
std::atomic_store_explicit(std::shared_ptr)
std::atomic_exchange(std::shared_ptr)
std::atomic_exchange_explicit(std::shared_ptr)
std::atomic_compare_exchange_weak(std::shared_ptr)
std::atomic_compare_exchange_strong(std::shared_ptr)
std::atomic_compare_exchange_weak_explicit(std::shared_ptr)
std::atomic_compare_exchange_strong_explicit(std::shared_ptr)
(deprecated in C++20)