What does boost::condition_variable::timed_wait() return on spurious wakeups?

不羁的心 提交于 2019-12-13 17:06:32

问题


The boost documentation says:

Returns: false if the call is returning because the time specified by abs_time was reached, true otherwise.

But what is returned if there is a spurious wakeup?


回答1:


If the condition variable could figure that it is a spurious wake-up there would be no need to return, would it?

You need to check if the data protected by the mutex and the condition variable has changed to detect a spurious wake-up. The condition variable can not do that for you.



来源:https://stackoverflow.com/questions/4669995/what-does-boostcondition-variabletimed-wait-return-on-spurious-wakeups

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