The Atomic Flag
This lesson gives an overview of the atomic flag, which is used from the perspective of concurrency in C++.
We'll cover the following...
We'll cover the following...
The atomic flag, i.e. std::atomic_flag, has a very simple interface. Its clear method enables you to set its value to false; with the test_and_set method you can set the value back to true. There is no method to exclusively ask for the current value. To use std::atomic_flag it must be initialized to false with the constant ATOMIC_FLAG_INIT. std::atomic_flag has two outstanding properties.
std::atomic_flag is:
- the only lock-free atomic. A non-blocking algorithm is lock-free if there is guaranteed system-wide progress.
- the building block for higher level