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

家住魔仙堡 提交于 2020-04-30 06:28:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!