- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
class Foo {
    std::atomic<bool> a{false};
    std::atomic<bool> b{false};
public:
    Foo()
    {
        
    }
    void first(function<void()> printFirst) {
        printFirst();
        a.store(true, std::memory_order_release);
    }
    void second(function<void()> printSecond) {
        while (!a.load(std::memory_order_acquire))
            ;
        printSecond();
        b.store(true, std::memory_order_release);
    }
    void third(function<void()> printThird) {
        while (!b.load(std::memory_order_acquire))
            ;
        printThird();
    }
};
 Follow us!
 Follow us!