简体   繁体   中英

std::condition_variable checks the condition for the first time, or do you have to wait for someone to make a notify?

std::condition_variable checks the condition for the first time, or do you have to wait for someone to make a notify?

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM