原子操作库
来自cppreference.com
< cpp
![]() |
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
原子库提供了细粒度的原子操作组件,允许无锁的并发编程。每一个原子操作与其他任何涉及到同一个对象的原子操作是不可分割的。原子对象是唯一没有数据竞争的C++对象,也就是说,如果一个线程对原子对象进行改写的同时有另一个线程对该对象进行读取,其行为是定义良好的.
在头文件
<atomic> 中定义 | |
| |
(C++11) |
原子类模板及其布尔型,整型和指针类型的特化 (类模板) |
(C++11) |
检查对该原子类型的操作是否是无锁的 (函数模板) |
| |
(C++11) (C++11) |
以原子方式将原子对象的值替换为非原子对象的值 原文: atomically replaces the value of the atomic object with a non-atomic argument (函数模板) |
(C++11) (C++11) |
以原子方式获取原子对象中的值 原文: atomically obtains the value stored in an atomic object (函数模板) |
(C++11) (C++11) |
以原子方式将原子对象的值替换为非原子对象的值,并返回原子对象的旧值 原文: atomically replaces the value of the atomic object with non-atomic argument and returns the old value of the atomic (函数模板) |
以原子方式比较原子对象和非原子对象的值,如果相等则执行原子交换,如果不相等则执行原子加载 原文: atomically compares the value of the atomic object with non-atomic argument and performs atomic exchange if equal or atomic load if not (函数模板) | |
(C++11) (C++11) |
向原子对象的值中添加非原子对象的值,并返回原子对象的旧值 原文: adds a non-atomic value to an atomic object and obtains the previous value of the atomic (函数模板) |
(C++11) (C++11) |
从原子对象的值中减去非原子对象的值,并返回原子对象的旧值 原文: subtracts a non-atomic value from an atomic object and obtains the previous value of the atomic (函数模板) |
(C++11) (C++11) |
将原子对象的值替换为它和非原子对象的值的逻辑AND结果,并返回旧值 原文: replaces the atomic object with the result of logical AND with a non-atomic argument and obtains the previous value of the atomic (函数模板) |
(C++11) (C++11) |
将原子对象的值替换为它和非原子对象的值的逻辑OR结果,并返回旧值 原文: replaces the atomic object with the result of logical OR with a non-atomic argument and obtains the previous value of the atomic (函数模板) |
(C++11) (C++11) |
将原子对象的值替换为它和非原子对象的值的逻辑XOR结果,并返回旧值 原文: replaces the atomic object with the result of logical XOR with a non-atomic argument and obtains the previous value of the atomic (函数模板) |
| |
(C++11) |
无锁的布尔原子类型 (类) |
以原子方式设置标志为true,并返回其先前的值 原文: atomically sets the flag to true and returns its previous value (函数) | |
(C++11) (C++11) |
以原子方式设置标志为false 原文: atomically sets the value of the flag to false (函数) |
| |
(C++11) |
默认构造的原子对象的非原子初始化 (函数模板) |
(C++11) |
一个原子变量,表示常量初始化的静态存储持续时间 原文: constant initialization of an atomic variable of static storage duration (函数宏) |
(C++11) |
将 std::atomic_flag 初始化为 false (常量宏) |
内存同步顺序 | |
(C++11) |
为给定的原子操作定义内存排序约束 (typedef) |
(C++11) |
从std::memory_order_consume的依赖关系树中删除指定的对象 原文: removes the specified object from the std::memory_order_consume dependency tree (函数模板) |
(C++11) |
通用的内存顺序相关的的栅栏同步原语 原文: generic memory order-dependent fence synchronization primitive (函数) |
(C++11) |
执行在同一线程的,线程和信号处理器之间的栅栏 原文: fence between a thread and a signal handler executed in the same thread (函数) |
[编辑] 另见
C语言文档 for 原子操作库
|