atomic_flag Structure

 

For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.

For the latest documentation on Visual Studio 2017, see atomic_flag Structure on docs.microsoft.com. Describes an object that atomically sets and clears a bool flag. Operations on atomic flags are always lock-free.

struct atomic_flag;

Public Methods

NameDescription
atomic_flag::clear MethodSets the stored flag to false.
atomic_flag::test_and_set MethodSets the stored flag to true and returns the initial flag value.

atomic_flag objects can be passed to the non-member functions atomic_flag_clear, atomic_flag_clear_explicit, atomic_flag_test_and_set, and atomic_flag_test_and_set_explicit. They can be initialized by using the value ATOMIC_FLAG_INIT.

Header: atomic

Namespace: std

Sets the bool flag that is stored in *this to false, within the specified memory_order constraints.

void atomic_flag::clear(memory_order Order = memory_order_seq_cst) volatile noexcept;
void atomic_flag::clear(memory_order Order = memory_order_seq_cst) noexcept;

Parameters

Order
A memory_order.

Sets the bool flag that is stored in *this to true, within the specified memory_order constraints.

bool atomic_flag::test_and_set(memory_order Order = memory_order_seq_cst) volatile noexcept;
bool atomic_flag::test_and_set(memory_order Order = memory_order_seq_cst) noexcept;

Parameters

Order
A memory_order.

Return Value

The initial value of the flag that is stored in *this.

<atomic>

Show: