...

/

Thread-Safe Initialization: call_once and once_flag

Thread-Safe Initialization: call_once and once_flag

This lesson gives an overview of thread-safe initialization in the perspective of concurrency in C++.

We'll cover the following...

By using the std::call_once function you can register a callable. The std::once_flag ensures that only one registered function will be invoked, but you can register additional functions via the same std::once_flag. That being said, only one function from that group is called.

std::call_once obeys the following rules:

  • Exactly one execution of exactly one of the functions is
...
Access this course and 1400+ top-rated courses and projects.