问题
std::condition_variable checks the condition for the first time, or do you have to wait for someone to make a notify?
回答1:
This is answered by reading documentation.
It's like:
while (!pred()) {
wait(lock);
}
So, the condition is checked first.
This can also be shown by testing it (though, to be fair, it's hard to know just from that whether the results are deterministic).
来源:https://stackoverflow.com/questions/61107175/stdcondition-variable-checks-the-condition-for-the-first-time-or-do-you-have