NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
atomic_futex< WaiterBit > 模板类 参考

原子快速用户态互斥锁类模板 更多...

#include <atomic_futex.hpp>

Public 成员函数

constexpr atomic_futex (const uint32_t data)
 构造函数
uint32_t load (const memory_order mo) const noexcept
 原子加载数据
uint32_t load_when_not_equal (const uint32_t value, const memory_order mo)
 等待直到值不等于指定值
void load_when_equal (const uint32_t value, const memory_order mo)
 等待直到值等于指定值
template<typename Rep, typename Period>
bool load_when_equal_for (const uint32_t value, const memory_order mo, const duration< Rep, Period > &rtime)
 在指定时间内等待值等于指定值
template<typename Clock, typename Dur>
bool load_when_equal_until (const uint32_t value, const memory_order mo, const time_point< Clock, Dur > &atime)
 在指定时间点前等待值等于指定值(通用时钟)
template<typename Dur>
bool load_when_equal_until (const uint32_t value, const memory_order mo, const time_point< system_clock, Dur > &atime)
 在指定时间点前等待值等于指定值(系统时钟)
template<typename Dur>
bool load_when_equal_until (const uint32_t value, const memory_order mo, const time_point< steady_clock, Dur > &atime)
 在指定时间点前等待值等于指定值(单调时钟)
bool compare_exchange_strong (uint32_t &expected, const uint32_t desired, const memory_order success, const memory_order failure) noexcept
 原子比较并交换
void store_notify_all (const uint32_t value, const memory_order mo) noexcept
 存储新值并通知所有等待线程

详细描述

template<uint32_t WaiterBit = 0x80000000>
class atomic_futex< WaiterBit >

原子快速用户态互斥锁类模板

模板参数
WaiterBit等待者标志位,默认为0x80000000

基于FUTEX实现的用户态互斥锁, 提供高效的线程同步机制,减少不必要的上下文切换。

在文件 atomic_futex.hpp37 行定义.

构造及析构函数说明

◆ atomic_futex()

template<uint32_t WaiterBit = 0x80000000>
atomic_futex< WaiterBit >::atomic_futex ( const uint32_t data)
inlineexplicitconstexpr

构造函数

参数
data初始数据值

在文件 atomic_futex.hpp142 行定义.

引用了 data().

成员函数说明

◆ compare_exchange_strong()

template<uint32_t WaiterBit = 0x80000000>
bool atomic_futex< WaiterBit >::compare_exchange_strong ( uint32_t & expected,
const uint32_t desired,
const memory_order success,
const memory_order failure )
inlinenoexcept

原子比较并交换

参数
expected期望值(必须包含 WaiterBit 的可能状态)
desired新值
success成功时的内存顺序
failure失败时的内存顺序
返回
是否交换成功
注解
直接操作内部原子变量,调用者需自行处理 WaiterBit 的语义

在文件 atomic_futex.hpp275 行定义.

引用了 success.

被这些函数引用 once_flag::call_once.

◆ load()

template<uint32_t WaiterBit = 0x80000000>
uint32_t atomic_futex< WaiterBit >::load ( const memory_order mo) const
inlinenodiscardnoexcept

原子加载数据

参数
mo内存顺序
返回
加载的数据值(清除等待者标志位)
注解
清除等待者标志位,只返回实际数据

在文件 atomic_futex.hpp152 行定义.

被这些函数引用 once_flag::call_once, load_when_equal(), load_when_equal_until(), load_when_equal_until() , 以及 load_when_not_equal().

◆ load_when_equal()

template<uint32_t WaiterBit = 0x80000000>
void atomic_futex< WaiterBit >::load_when_equal ( const uint32_t value,
const memory_order mo )
inline

等待直到值等于指定值

参数
value期望相等的值
mo内存顺序

阻塞当前线程,直到数据值等于指定的值。

在文件 atomic_futex.hpp179 行定义.

引用了 load().

◆ load_when_equal_for()

template<uint32_t WaiterBit = 0x80000000>
template<typename Rep, typename Period>
bool atomic_futex< WaiterBit >::load_when_equal_for ( const uint32_t value,
const memory_order mo,
const duration< Rep, Period > & rtime )
inline

在指定时间内等待值等于指定值

模板参数
Rep时间表示类型
Period时间单位比例
参数
value期望相等的值
mo内存顺序
rtime相对超时时间
返回
是否在超时前等到相等

在文件 atomic_futex.hpp197 行定义.

引用了 ceil(), load_when_equal_until() , 以及 steady_clock::now().

◆ load_when_equal_until() [1/3]

template<uint32_t WaiterBit = 0x80000000>
template<typename Clock, typename Dur>
bool atomic_futex< WaiterBit >::load_when_equal_until ( const uint32_t value,
const memory_order mo,
const time_point< Clock, Dur > & atime )
inline

在指定时间点前等待值等于指定值(通用时钟)

模板参数
Clock时钟类型
Dur持续时间类型
参数
value期望相等的值
mo内存顺序
atime绝对超时时间点
返回
是否在超时前等到相等
注解
将其他时钟转换为单调时钟进行处理

在文件 atomic_futex.hpp215 行定义.

引用了 ceil(), load_when_equal_until() , 以及 steady_clock::now().

被这些函数引用 load_when_equal_for() , 以及 load_when_equal_until().

◆ load_when_equal_until() [2/3]

template<uint32_t WaiterBit = 0x80000000>
template<typename Dur>
bool atomic_futex< WaiterBit >::load_when_equal_until ( const uint32_t value,
const memory_order mo,
const time_point< steady_clock, Dur > & atime )
inline

在指定时间点前等待值等于指定值(单调时钟)

模板参数
Dur持续时间类型
参数
value期望相等的值
mo内存顺序
atime绝对超时时间点(单调时钟)
返回
是否在超时前等到相等

在文件 atomic_futex.hpp256 行定义.

引用了 load().

◆ load_when_equal_until() [3/3]

template<uint32_t WaiterBit = 0x80000000>
template<typename Dur>
bool atomic_futex< WaiterBit >::load_when_equal_until ( const uint32_t value,
const memory_order mo,
const time_point< system_clock, Dur > & atime )
inline

在指定时间点前等待值等于指定值(系统时钟)

模板参数
Dur持续时间类型
参数
value期望相等的值
mo内存顺序
atime绝对超时时间点
返回
是否在超时前等到相等

在文件 atomic_futex.hpp237 行定义.

引用了 load().

◆ load_when_not_equal()

template<uint32_t WaiterBit = 0x80000000>
uint32_t atomic_futex< WaiterBit >::load_when_not_equal ( const uint32_t value,
const memory_order mo )
inline

等待直到值不等于指定值

参数
value期望不相等的值
mo内存顺序
返回
当前值(当不等于指定值时)

阻塞当前线程,直到数据值不等于指定的值。

在文件 atomic_futex.hpp164 行定义.

引用了 load().

被这些函数引用 once_flag::call_once.

◆ store_notify_all()

template<uint32_t WaiterBit = 0x80000000>
void atomic_futex< WaiterBit >::store_notify_all ( const uint32_t value,
const memory_order mo )
inlinenoexcept

存储新值并通知所有等待线程

参数
value要存储的值
mo内存顺序

原子地存储新值,如果有等待线程,则唤醒所有等待线程。

在文件 atomic_futex.hpp288 行定义.

引用了 futex_notify().

被这些函数引用 once_flag::call_once.


该类的文档由以下文件生成: