c++ - Can std::this_thread::sleep_for() have spurious wakeups? -
note, not question std::condition_variable::wait_for()
. know can wake spuriously.
my program’s behavior suggests answer question yes, stl documentation quite clear condition_variable case. @ least @ cppreference.com, correct answer this_thread appears no.
compiler gcc 4.8.1, in case defect.
the relevant sections of c++ standard (paragraphs [thread.thread.this]/7-9) not mention spurious wake-ups std::this_thread::sleep_for
, unlike e.g. std::condition_variable::wait_for
.
template <class rep, class period> void sleep_for(const chrono::duration<rep, period>& rel_time);
7 effects: blocks calling thread relative timeout (30.2.4) specified
rel_time
.8 synchronization: none.
9 throws: timeout-related exceptions (30.2.4).
this implies behavior observing non-conforming.
Comments
Post a Comment