![](/img/trans.png)
[英]C++11 std::this_thread::sleep_until() hangs when compiled with GCC 4.8.5
[英]C++11 std::this_thread - How to cancel sleep_until ()?
有沒有辦法“取消”:
std::this_thread::sleep_until(now + std::chrono::milliseconds(200));
讓我們假設以下場景:
我將我的線程設置為在200ms內喚醒...但是在10ms之后,我收到一個新請求,我的線程必須在100ms內喚醒...
所以線程應該喚醒:100ms然后是200ms(當然是在當前時間之后)。
謝謝 :)
我不認為你可以用sleep_until
做到這sleep_until
。 查看條件變量( http://www.cplusplus.com/reference/condition_variable/condition_variable/ )。 應該可以用於你想要的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.