1#ifndef NEFORCE_CORE_ASYNC_LATCH_HPP__
2#define NEFORCE_CORE_ASYNC_LATCH_HPP__
13NEFORCE_BEGIN_NAMESPACE__
71 if (old_value == update) {
82 NEFORCE_ALWAYS_INLINE
bool try_wait() const noexcept {
93 NEFORCE_ALWAYS_INLINE
void wait() const noexcept {
94 auto const predicate = [
this] {
return this->
try_wait(); };
117NEFORCE_END_NAMESPACE__
latch(const latch &)=delete
禁止拷贝构造
NEFORCE_ALWAYS_INLINE void wait() const noexcept
等待计数器为零
latch & operator=(const latch &)=delete
禁止拷贝赋值
constexpr latch(const platform_wait_t expected) noexcept
构造函数
NEFORCE_ALWAYS_INLINE bool try_wait() const noexcept
尝试等待
NEFORCE_ALWAYS_INLINE void arrive_and_wait(const platform_wait_t update=1) noexcept
减少计数器并等待
static constexpr platform_wait_t max() noexcept
获取闩锁的最大计数值
NEFORCE_ALWAYS_INLINE void count_down(const platform_wait_t update=1)
减少计数器
static NEFORCE_NODISCARD constexpr T max() noexcept
获取类型的最大值
NEFORCE_ALWAYS_INLINE_INLINE remove_volatile_t< T > atomic_fetch_sub(volatile T *ptr, atomic_diff_t< T > value, const memory_order mo) noexcept
原子获取并减去操作
void atomic_wait_address(const T *addr, Pred pred) noexcept
基于谓词的原子等待
void atomic_notify_address(const T *addr, const bool all) noexcept
原子通知
NEFORCE_ALWAYS_INLINE_INLINE remove_volatile_t< T > atomic_load(const volatile T *ptr, const memory_order mo) noexcept
原子加载操作
#define NEFORCE_CONSTEXPR_ASSERT(COND)
编译时常量断言
int platform_wait_t
平台等待类型别名
NEFORCE_INLINE17 constexpr auto memory_order_release
释放内存顺序常量
NEFORCE_INLINE17 constexpr auto memory_order_acquire
获取内存顺序常量