1#ifndef MSTL_CORE_ASYNC_CALL_ONCE_HPP__
2#define MSTL_CORE_ASYNC_CALL_ONCE_HPP__
34 template <
typename Callable,
typename... Args>
64template <
typename Callable,
typename... Args>
73 if (state == 2)
return;
97 if (spin_count < 10) {
98 for (
uint32_t i = 0; i < (1u << spin_count); ++i) {
103 this_thread::yield();
friend void call_once(once_flag &flag, Callable &&func, Args &&... args)
单次调用函数
MSTL_NODISCARD constexpr T && forward(remove_reference_t< T > &x) noexcept
完美转发左值
void call_once(once_flag &flag, Callable &&func, Args &&... args)
单次调用函数
unsigned int uint32_t
32位无符号整数类型
MSTL_CONSTEXPR14 _INNER __invoke_result_aux< Callable, Args... >::type invoke(Callable &&f, Args &&... args) noexcept(is_nothrow_invocable< Callable, Args... >::value)
统一调用接口
MSTL_INLINE17 constexpr auto memory_order_release
释放内存顺序常量
MSTL_INLINE17 constexpr auto memory_order_acq_rel
获取-释放内存顺序常量
MSTL_INLINE17 constexpr auto memory_order_relaxed
宽松内存顺序常量
MSTL_INLINE17 constexpr auto memory_order_acquire
获取内存顺序常量
#define _MSTL
全局命名空间MSTL前缀
#define MSTL_END_NAMESPACE__
结束全局命名空间MSTL
#define MSTL_BEGIN_NAMESPACE__
开始全局命名空间MSTL
T load(const memory_order mo=memory_order_seq_cst) const noexcept
原子加载操作
bool compare_exchange_strong(T &expected, T desired, const memory_order success, const memory_order failure) noexcept
强比较交换操作
void store(T value, const memory_order mo=memory_order_seq_cst) noexcept
原子存储操作