Atomic operations library

原子操作库

如果宏常量__STDC_NO_ATOMICS__(C11)由编译器定义,则不提供此处列出的标题<stdatomic.h>,关键字_Atomic和所有名称。

类型

| Defined in header <stdatomic.h> |

|:----|

| memory_order(C11)| 定义内存排序约束(枚举)|

| atomic_flag(C11)| 无锁原子布尔标志(结构)|

| Defined in header <stdatomic.h> |

|:----|

| ATOMIC_BOOL_LOCK_FREEATOMIC_CHAR_LOCK_FREEATOMIC_CHAR16_T_LOCK_FREEATOMIC_CHAR32_T_LOCK_FREEATOMIC_WCHAR_T_LOCK_FREEATOMIC_SHORT_LOCK_FREEATOMIC_INT_LOCK_FREEATOMIC_LONG_LOCK_FREEATOMIC_LLONG_LOCK_FREEATOMIC_POINTER_LOCK_FREE(C11)| 表明给定的原子类型是无锁的(宏常量)|

| ATOMIC_FLAG_INIT(C11)| 初始化一个新的atomic_flag(宏常量)|

| ATOMIC_VAR_INIT(C11)| 初始化一个新的原子对象(函数宏)|

| kill_dependency(C11)| 为memory_order_consume(函数宏)|打破依赖关系链

函数

| Defined in header <stdatomic.h> |

|:----|

| atomic_flag_test_and_setatomic_flag_test_and_set_explicit(C11)| 将atomic_flag设置为true并返回旧值(函数)|

| atomic_flag_clearatomic_flag_clear_explicit(C11)| 将atomic_flag设置为false(函数)|

| atomic_init(C11)| 初始化现有的原子对象(函数)|

| atomic_is_lock_free(C11)| 指示原子对象是否为无锁(函数)|

| atomic_storeatomic_store_explicit(C11)| 将值存储在原子对象(函数)|中

| atomic_loadatomic_load_explicit(C11)| 从原子对象(函数)|读取一个值

| atomic_exchangeatomic_exchange_explicit(C11)| 用原子对象(函数)|的值交换一个值

| atomic_compare_exchange_strongatomic_compare_exchange_strong_explicitatomic_compare_exchange_weakatomic_compare_exchange_weak_explicit(C11)| 如果旧值是预期值,则用原子对象交换值,否则读取旧值(函数)|

| atomic_fetch_addatomic_fetch_add_explicit(C11)| 原子添加(功能)|

| atomic_fetch_subatomic_fetch_sub_explicit(C11)| 原子减法(函数)|

| atomic_fetch_oratomic_fetch_or_explicit(C11)| 原子逻辑OR(功能)|

| atomic_fetch_xoratomic_fetch_xor_explicit(C11)| 原子逻辑异或(函数)|

| atomic_fetch_andatomic_fetch_and_explicit(C11)| 原子逻辑AND(函数)|

| atomic_thread_fence(C11)| 通用内存顺序依赖的栅栏同步原语(函数)|

| atomic_signal_fence(C11)| 在同一线程(函数)|中执行的线程和信号处理程序之间的栅栏

类型

标准库为核心语言原子类型提供了方便的typedef。

Typedef name全类型伞
atomic_bool_Atomic _Bool
atomic_char_Atomic char
atomic_schar_Atomic signed char
atomic_uchar_Atomic unsigned char
atomic_short_Atomic short
atomic_ushort_Atomic unsigned short
atomic_int_Atomic int
atomic_uint_Atomic unsigned int
atomic_long_Atomic long
atomic_ulong_Atomic unsigned long
atomic_llong_Atomic long long
atomic_ullong_Atomic unsigned long long
atomic_char16_t_Atomic char16_t
atomic_char32_t_Atomic char32_t
atomic_wchar_t_Atomic wchar_t
atomic_int_least8_t_Atomic int_least8_t
atomic_uint_least8_t_Atomic uint_least8_t
atomic_int_least16_t_Atomic int_least16_t
atomic_uint_least16_t_Atomic uint_least16_t
atomic_int_least32_t_Atomic int_least32_t
atomic_uint_least32_t_Atomic uint_least32_t
atomic_int_least64_t_Atomic int_least64_t
atomic_uint_least64_t_Atomic uint_least64_t
atomic_int_fast8_t_Atomic int_fast8_t
atomic_uint_fast8_t_Atomic uint_fast8_t
atomic_int_fast16_t_Atomic int_fast16_t
atomic_uint_fast16_t_Atomic uint_fast16_t
atomic_int_fast32_t_Atomic int_fast32_t
atomic_uint_fast32_t_Atomic uint_fast32_t
atomic_int_fast64_t_Atomic int_fast64_t
atomic_uint_fast64_t_Atomic uint_fast64_t
atomic_intptr_t_Atomic intptr_t
atomic_uintptr_t_Atomic uintptr_t
atomic_size_t_Atomic size_t
atomic_ptrdiff_t_Atomic ptrdiff_t
atomic_intmax_t_Atomic intmax_t
atomic_uintmax_t_Atomic uintmax_t

参考

  • C11 standard (ISO/IEC 9899:2011):

另请参阅

| 用于Atomic操作库的C ++文档

|:----|