Skip to content
UPEEC

std::condition_variable

Wait until another thread signals that a condition holds.

Advanced
Comments 0
std::unique_lock lk(m);
cv.wait(lk, [&]{ return !queue.empty(); });

Always wait with a predicate to handle spurious wake-ups.

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.