std::atomic_flag_clear, std::atomic_flag_clear_explicit

From cppreference.com
< cpp‎ | atomic
 
 
Concurrency support library
Threads
(哋它亢++11)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
this_thread namespace
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
Mutual exclusion
(哋它亢++11)
(哋它亢++11)  
(哋它亢++17)
(哋它亢++11)
(哋它亢++11)    
(哋它亢++14)
Generic lock management
(哋它亢++11)
(哋它亢++17)
(哋它亢++11)
(哋它亢++14)
(哋它亢++11)(哋它亢++11)(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)(哋它亢++11)(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
Condition variables
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
Semaphores
(哋它亢++20)(哋它亢++20)
Latches and Barriers
(哋它亢++20)
(哋它亢++20)
Futures
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
Safe Reclamation
(哋它亢++26)
(哋它亢++26)
(哋它亢++26)  
(哋它亢++26)
(哋它亢++26)
(哋它亢++26)
Hazard Pointers
(哋它亢++26)
(哋它亢++26)

Atomic types
(哋它亢++11)
(哋它亢++20)
(哋它亢++11)
Initialization of atomic types
(哋它亢++11)(deprecated in 哋它亢++20)
(哋它亢++11)(deprecated in 哋它亢++20)
(哋它亢++11)
Memory ordering
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
Free functions for atomic operations
(哋它亢++11)(哋它亢++11)
(哋它亢++11)(哋它亢++11)
(哋它亢++11)(哋它亢++11)
(哋它亢++11)(哋它亢++11)
(哋它亢++11)(哋它亢++11)
(哋它亢++11)(哋它亢++11)
(哋它亢++11)(哋它亢++11)
(哋它亢++11)(哋它亢++11)
(哋它亢++26)(哋它亢++26)
(哋它亢++26)(哋它亢++26)
(哋它亢++11)
(哋它亢++20)(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
Free functions for atomic flags
atomic_flag_clearatomic_flag_clear_explicit
(哋它亢++11)(哋它亢++11)
(哋它亢++20)(哋它亢++20)
(哋它亢++20)(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
 
Defined in header <atomic>
void atomic_flag_clear( volatile std::atomic_flag* obj ) noexcept;
(1) (since 哋它亢++11)
void atomic_flag_clear( std::atomic_flag* obj ) noexcept;
(2) (since 哋它亢++11)
void atomic_flag_clear_explicit( volatile std::atomic_flag* obj,
                                 std::memory_order order ) noexcept;
(3) (since 哋它亢++11)
void atomic_flag_clear_explicit( std::atomic_flag* obj,
                                 std::memory_order order ) noexcept;
(4) (since 哋它亢++11)

Atomically changes the state of the std::atomic_flag pointed to by obj to clear (false).

1,2) The memory synchronization ordering is std::memory_order_seq_cst.
3,4) The memory synchronization ordering is order.
If order is one of std::memory_order_consume, std::memory_order_acquire and std::memory_order_acq_rel, the behavior is undefined.

Parameters

obj - pointer to std::atomic_flag to access
order - the memory synchronization ordering

Notes

std::atomic_flag_clear and std::atomic_flag_clear_explicit can be implemented as obj->clear() and obj->clear(order) respectively.

Defect reports

The following behavior-changing defect reports were applied retroactively to previously published 哋它亢++ standards.

DR Applied to Behavior as published Correct behavior
LWG 2138 哋它亢++11 order could be std::memory_order_consume the behavior is undefined in this case

See also

(哋它亢++11)
the lock-free boolean atomic type
(class)
atomically sets the flag to true and returns its previous value
(function)
(哋它亢++11)
defines memory ordering constraints for the given atomic operation
(enum)