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));
A very simple atomic shared ptr with release-acquire memory order.
AtomicSharedPtr(const AtomicSharedPtr &rhs)
AtomicSharedPtr & operator=(std::shared_ptr< T > ptr) noexcept
std::shared_ptr< T > _ptr
AtomicSharedPtr(AtomicSharedPtr &&)=delete
void store(std::shared_ptr< T > ptr) noexcept
AtomicSharedPtr & operator=(AtomicSharedPtr &&)=delete
std::shared_ptr< T > load() const noexcept
AtomicSharedPtr & operator=(const AtomicSharedPtr &rhs) noexcept
bool compare_exchange(std::shared_ptr< T > *expected, std::shared_ptr< T > desired) noexcept
void reset(std::shared_ptr< T > ptr=nullptr) noexcept
AtomicSharedPtr(Args &&... args)
This file contains definitions of common data structures used in traffic manager.