std::atomic_ref<T>:: is_lock_free
From cppreference.net
<
cpp
|
atomic
|
atomic ref
C++
Concurrency support library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::atomic_ref
| Member functions | ||||
|
atomic_ref::is_lock_free
|
||||
|
(C++26)
|
||||
|
Operations for arithmetic types
(except
bool
and pointer-to-object)
|
||||
|
Operations for integral types
(except
bool
and pointer-to-object)
|
||||
|
(C++26)
|
||||
|
(C++26)
|
||||
|
Operations for integral types
(except
bool
)
|
||||
| Constants | ||||
|
bool
is_lock_free
(
)
const
noexcept
;
|
(C++20 起) | |
检查此对象的原子操作是否无锁。
目录 |
参数
(无)
返回值
true 表示该对象的原子操作是无锁的, false 则表示相反情况。
注释
除 std::atomic_flag 外的所有原子类型,均可通过互斥锁或其他锁定操作实现,而非必须使用无锁的原子CPU指令。原子类型也允许 有时 具备无锁特性,例如在特定架构中若仅对齐内存访问本身是原子的,则同类型的未对齐对象必须使用锁机制。
C++标准建议(但不强制要求)无锁原子操作同时也是地址无关的,即适用于使用共享内存的进程间通信。
示例
|
本节内容不完整
原因:缺少示例 |
参见
|
[static]
|
指示该类型始终是无锁的
(公开静态成员常量) |