Namespaces
Variants

std::atomic_flag:: test_and_set

From cppreference.net
Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
Cooperative cancellation
Mutual exclusion
Generic lock management
Condition variables
(C++11)
Semaphores
Latches and Barriers
(C++20)
(C++20)
Futures
(C++11)
(C++11)
(C++11)
Safe reclamation
Hazard pointers
Atomic types
(C++11)
(C++20)
Initialization of atomic types
(C++11) (deprecated in C++20)
(C++11) (deprecated in C++20)
Memory ordering
(C++11) (deprecated in C++26)
Free functions for atomic operations
Free functions for atomic flags
定义于头文件 <atomic>
bool test_and_set ( std:: memory_order order =
std:: memory_order_seq_cst ) volatile noexcept ;
(1) (C++11 起)
bool test_and_set ( std:: memory_order order =
std:: memory_order_seq_cst ) noexcept ;
(2) (C++11 起)

以原子方式将 std::atomic_flag 的状态更改为置位状态( true ),并返回其先前持有的值。

参数

order - 内存同步顺序

参见

原子地将标志设置为 false
(公开成员函数)
原子地将标志设置为 true 并返回其先前值
(函数)
为给定的原子操作定义内存排序约束
(枚举)