std::atomic_flag initialization with ATOMIC_FLAG_INIT
An instance of std::atomic_flag may be initialized using the ATOMIC_FLAG_INIT macro, in which case it’s initialized into the clear state. For objects of static storage duration, initialization shall be static initialization.
- Declaration
#define ATOMIC_FLAG_INIT unspecified
- Usage
std::atomic_flag flag=ATOMIC_FLAG_INIT;
- Effects Constructs a new std::atomic_flag object in the clear state.
- Throws Nothing.
std::atomic_flag::test_and_set member function
Atomically sets the flag and checks whether or not it was set.
- Declaration
bool test_and_set(memory_order order = memory_order_seq_cst) volatile noexcept; bool test_and_set(memory_order order = memory_order_seq_cst) noexcept; ...
Get C++ Concurrency in Action, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.