3#include <yaclib/config.hpp>
8#include <yaclib_std/atomic>
12template <
typename CounterBase,
typename Deleter = DefaultDeleter>
14 template <
typename...
Args>
20 count.fetch_add(
delta, std::memory_order_relaxed);
25 Deleter::Delete(*
this);
31 return count.load(std::memory_order_acquire);
36 return count.fetch_sub(
n, std::memory_order_acq_rel) ==
n;
40 if (
count.fetch_sub(
n, std::memory_order_release) ==
n) {
41 yaclib_std::atomic_thread_fence(std::memory_order_acquire);
atomic< std::size_t > atomic_size_t
Contract< V, E > MakeContract()
Creates related future and promise.
YACLIB_INLINE bool SubEqual(std::size_t n) noexcept
YACLIB_INLINE void Sub(std::size_t delta) noexcept
yaclib_std::atomic_size_t count
std::size_t GetRef() const noexcept
YACLIB_INLINE void Add(std::size_t delta) noexcept
AtomicCounter(std::size_t n, Args &&... args) noexcept(std::is_nothrow_constructible_v< CounterBase, Args &&... >)