Skip to content

Latest commit

 

History

History
72 lines (47 loc) · 2.42 KB

atomic-flag-structure.md

File metadata and controls

72 lines (47 loc) · 2.42 KB
description title ms.date f1_keywords ms.assetid ms.custom
Learn more about: atomic_flag Structure
atomic_flag Structure
06/07/2022
atomic/std::atomic_flag
atomic/std::atomic_flag::clear
atomic/std::atomic_flag::test_and_set
17f0c2f5-fd39-4a44-873a-b569720a670e
devdivchpfy22

atomic_flag Structure

Describes an object that atomically sets and clears a bool flag. Operations on atomic flags are always lock-free.

Syntax

struct atomic_flag;

Members

Public Methods

Name Description
clear Sets the stored flag to false.
test_and_set Sets the stored flag to true and returns the initial flag value.

Remarks

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.

Requirements

Header: <atomic>

Namespace: std

atomic_flag::clear

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.

atomic_flag::test_and_set

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.

See also

<atomic>