I have read Concurrency: Atomic and volatile in C++11 memory model and How std::memory_order_seq_cst works, it doesn't help much and answer my question directly.
From https://en.cppreference.com/w/cpp/thread/condition_variable/notify_one:
The effects of
notify_one()
/notify_all()
and each of the three atomic parts ofwait()
/wait_for()
/wait_until()
(unlock+wait, wakeup, and lock) take place in a single total order that can be viewed as modification order of an atomic variable: the order is specific to this individual condition_variable. This makes it impossible fornotify_one()
to, for example, be delayed and unblock a thread that started waiting just after the call tonotify_one()
was made.
What does it mean by saying "take place in a single total order"? How is this related to the next sentence "This makes it impossible ..... was made."? (It seems that it's telling a cause and effect).
I read it word by word more than 10 times and don't understand what it's saying.. Definition of "total order" from Wikipedia can't help much.