boost :: condition_variable :: timed_wait()返回虚假的唤醒是什么? [英] What does boost::condition_variable::timed_wait() return on spurious wakeups?

查看:272
本文介绍了boost :: condition_variable :: timed_wait()返回虚假的唤醒是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

boost文档说:


返回:
如果调用返回,因为abs_time指定的时间是达到,否则为真。

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?

推荐答案

如果条件变量可以认为它是一个虚假的唤醒,就不需要返回,会吗?

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.

这篇关于boost :: condition_variable :: timed_wait()返回虚假的唤醒是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆