Skip to content

Commit e3da46d

Browse files
committed
wait_for
1 parent 4532f81 commit e3da46d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cpp/11.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,12 @@ void condition_variable_11()
702702
cv.notify_one();
703703
});
704704
// locking block
705+
{
706+
unique_lock<mutex> lk(m);
707+
// https://en.cppreference.com/w/cpp/thread/condition_variable/wait_for
708+
assert(cv.wait_for(lk, chrono::milliseconds(0)) == cv_status::timeout);
709+
assert(!cv.wait_for(lk, chrono::milliseconds(0),[]{return false;}));
710+
}
705711
{
706712
unique_lock<mutex> lk(m);
707713
stage = 1;

0 commit comments

Comments
 (0)