18 template <
typename... Args>
20 :
_ptr(
std::forward<Args>(args)...) {}
27 void store(std::shared_ptr<T> ptr) noexcept {
28 std::atomic_store_explicit(&
_ptr, ptr, std::memory_order_release);
31 void reset(std::shared_ptr<T> ptr =
nullptr) noexcept {
35 std::shared_ptr<T>
load() const noexcept {
36 return std::atomic_load_explicit(&
_ptr, std::memory_order_acquire);
39 bool compare_exchange(std::shared_ptr<T> *expected, std::shared_ptr<T> desired) noexcept {
40 return std::atomic_compare_exchange_strong_explicit(
44 std::memory_order_acq_rel,
45 std::memory_order_acq_rel);
49 store(std::move(ptr));
std::shared_ptr< T > load() const noexcept
void store(std::shared_ptr< T > ptr) noexcept
AtomicSharedPtr(const AtomicSharedPtr &rhs)
This file contains definitions of common data structures used in traffic manager. ...
AtomicSharedPtr & operator=(const AtomicSharedPtr &rhs) noexcept
AtomicSharedPtr & operator=(std::shared_ptr< T > ptr) noexcept
bool compare_exchange(std::shared_ptr< T > *expected, std::shared_ptr< T > desired) noexcept
std::shared_ptr< T > _ptr
void reset(std::shared_ptr< T > ptr=nullptr) noexcept
A very simple atomic shared ptr with release-acquire memory order.
AtomicSharedPtr(Args &&... args)