ATOMIC_VAR_INIT
来自cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Defined in header <atomic>
|
||
| #define ATOMIC_VAR_INIT(value) /* implementation-defined */ |
||
展开的表达式可以被用来初始化一个对象,可以初始化从std::atomic
value。如果原子对象具有静态存储持续时间,这个初始化是常数初始化.Original:
Expands the an expression which can be used to initialize an std::atomic object that can be initialized from
value. If the atomic object has static storage duration, this initialization is 常数初始化.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 注释
从另一个线程访问的变量在初始化过程中,即使是通过一个原子操作,是数据争用(它可能发生,如果该地址被立即传递给std::memory_order_relaxed操作与另一个线程)
Original:
Accessing the variable during initialization from another thread, even through an atomic operation, is a data race (it may happen if the address is immediately passed to another thread with a std::memory_order_relaxed operation)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
这个宏主要是为了与C兼容,它的行为一样的构造函数std::atomic的
Original:
This macro is primarily provided for compatibility with C; it behaves the same as the constructor of std::atomic.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 为例
| 本节是不完整的 原因: no example |
[编辑] 另请参阅
| (C++11) |
non-atomic initialization of a default-constructed atomic object (函数模板) |
| 构建一个原子对象 Original: constructs an atomic object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数of std::atomic)
| |