std::atomic_store, std::atomic_store_explicit

定义于头文件 <atomic>
(1) (C++11 起)
template< class T >
void atomic_store( std::atomic<T>* obj, T desr ) noexcept;
template< class T >
void atomic_store( volatile std::atomic<T>* obj, T desr ) noexcept;
(2) (C++11 起)
template< class T >

void atomic_store_explicit( std::atomic<T>* obj, T desr,

                            std::memory_order order) noexcept;
template< class T >

void atomic_store_explicit( volatile std::atomic<T>* obj, T desr,

                            std::memory_order order) noexcept;
1) 如同用 obj->store(desr) 原子地以 desr 的值替换 obj 所指向的值。
2) 如同用 obj->store(desr, order) 原子地以 desr 的值替换 obj 所指向的值。

参数

obj - 指向要修改的原子对象的指针
desr - 要存储于原子对象的值
order - 此操作所用的内存同步顺序:只容许 std::memory_order_relaxedstd::memory_order_releasestd::memory_order_seq_cst

返回值

(无)

参阅

原子地以非原子对象替换原子对象的值
(std::atomic 的公开成员函数)
原子地获得存储于原子对象的值
(函数模板)
(C++11)
为给定的原子操作定义内存顺序制约
(typedef)
std::shared_ptr 特化原子操作
(函数模板)
atomic_store, atomic_store_explicitC 文档

版本历史

  • (当前 | 先前 2017年9月29日 (五) 20:59Fruderica讨论 | 贡献. . (1,816字节) (-783). . (撤销)
  • 当前 | 先前 2013年7月2日 (二) 07:18P12bot讨论 | 贡献 . . (2,599字节) (-229). . (Use {{lc}}. Update links. Various fixes.) (撤销)
  • 当前 | 先前 2012年11月2日 (五) 16:07P12bot讨论 | 贡献 . . (2,828字节) (+249). . (r2.7.3) (机器人添加:de, en, es, fr, it, ja, pt, ru) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 09:49P12讨论 | 贡献 . . (2,579字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 06:00TranslationBot讨论 | 贡献. . (2,579字节) (-65). . (Translated from the English version using Google Translate) (撤销)
  • 当前 | 先前 2012年10月25日 (四) 13:14P12讨论 | 贡献 . . (2,644字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前) 2012年10月25日 (四) 12:00TranslationBot讨论 | 贡献. . (2,644字节) (+2,644). . (Translated from the English version using Google Translate)