std::once_flag

From cppreference.com
< cpp‎ | thread
 
 
Thread support library
Threads
(C++11)
this_thread namespace
(C++11)
(C++11)
(C++11)
(C++11)
Mutual exclusion
(C++11)
(C++11)
Generic lock management
(C++11)
(C++11)
(C++14)
(C++11)
(C++11)
(C++11)(C++11)(C++11)
once_flag
(C++11)
(C++11)
Condition variables
(C++11)
Futures
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
 
Defined in header <mutex>
class once_flag;
(since C++11)

The class std::once_flag is a helper structure for std::call_once.

An object of type std::once_flag that is passed to multiple calls to std::call_once allows those calls to coordinate with each other such that only one of the calls will actually run to completion.

std::once_flag is noncopyable.

Contents

[edit] Member functions

std::once_flag::once_flag

constexpr once_flag();

Constructs an once_flag object. The internal state is set to indicate that no function has been called yet.

Parameters

(none)

Exceptions

noexcept specification:  
noexcept
  

[edit] See also

(C++11)
invokes a function only once even if called from multiple threads
(function template)