std::atomic_...<std::shared_ptr>
cppreference.com
<tbody>
</tbody>
template< class T > bool atomic_is_lock_free( const std::shared_ptr<T>* p ); |
(1) | ( C++11) ( C++20) |
template< class T > std::shared_ptr<T> atomic_load( const std::shared_ptr<T>* p ); |
(2) | ( C++11) ( C++20) |
template< class T > std::shared_ptr<T> atomic_load_explicit( const std::shared_ptr<T>* p, std::memory_order mo ); |
(3) | ( C++11) ( C++20) |
template< class T > void atomic_store( std::shared_ptr<T>* p, std::shared_ptr<T> r ); |
(4) | ( C++11) ( C++20) |
template< class T > void atomic_store_explicit( std::shared_ptr<T>* p, std::shared_ptr<T> r, std::memory_order mo); |
(5) | ( C++11) ( C++20) |
template< class T > std::shared_ptr<T> atomic_exchange( std::shared_ptr<T>* p, std::shared_ptr<T> r); |
(6) | ( C++11) ( C++20) |
template<class T> std::shared_ptr<T> atomic_exchange_explicit( std::shared_ptr<T>* p, std::shared_ptr<T> r, std::memory_order mo); |
(7) | ( C++11) ( C++20) |
template< class T > bool atomic_compare_exchange_weak( std::shared_ptr<T>* p, std::shared_ptr<T>* expected, std::shared_ptr<T> desired); |
(8) | ( C++11) ( C++20) |
template<class T> bool atomic_compare_exchange_strong( std::shared_ptr<T>* p, std::shared_ptr<T>* expected, std::shared_ptr<T> desired); |
(9) | ( C++11) ( C++20) |
template< class T > 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, std::memory_order failure); |
(10) | ( C++11) ( C++20) |
template< class T > 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, std::memory_order failure); |
(11) | ( C++11) ( C++20) |
std::shared_ptr , - shared_ptr, , , (std::atomic_load, std::atomic_store ..)
, shared_ptr : std::shared_ptr mutable , operator= reset, , .
1) , ,
p, .2)
atomic_load_explicit(p, std::memory_order_seq_cst)4)
atomic_store_explicit(p, r, memory_order_seq_cst)5)
r , p, p->swap(r). std::atomic_store_explicit, mo std::memory_order_acquire std::memory_order_acq_rel.6)
atomic_exchange_explicit(p, r, memory_order_seq_cst)7)
r , p, , p. p->swap(r) r .8)
atomic_compare_exchange_weak_explicit(p, expected, desired, std::memory_order_seq_cst,std::memory_order_seq_cst).
9)
atomic_compare_exchange_strong_explicit(p, expected, desired, std::memory_order_seq_cst,std::memory_order_seq_cst).
10) ,
p expected. ( , ), desired *p , success, true. , *p *expected , failure, false.11) , (10), .
, p .
| p, expected | std::shared_ptr | |
| r, desired | std::shared_ptr | |
| mo, success, failure | std::memory_order |
.
1)
true, 2,3) .
4,5) ()
6,7)
8,9,10,11)
true, , false ., -, .
, . , shared_ptr, shared_ptr, .
atomic_shared_ptr atomic_weak_ptr .
|
std::atomic: |
( C++20) |
| : |
C++:
| LWG 2980 | C++11 | shared_ptr
|
, |
(C++11) |
, ( ) |
(C++11)(C++11) |
( ) |
(C++11)(C++11) |
, ( ) |
(C++11)(C++11) |
( ) |
| , , , ( ) |