From fd649915f60fbf6e2efee5ffc274dee88b0437b7 Mon Sep 17 00:00:00 2001 From: Minjie Date: Tue, 4 Feb 2020 21:18:26 +0800 Subject: [PATCH] prevent spurious wake up --- countdownlatch.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/countdownlatch.cpp b/countdownlatch.cpp index e3bacfd..82466f3 100644 --- a/countdownlatch.cpp +++ b/countdownlatch.cpp @@ -13,7 +13,10 @@ void clatch::countdownlatch::await(uint64_t nanosecs) { if (nanosecs > 0) { cv.wait_for(lck, std::chrono::nanoseconds(nanosecs)); } else { - cv.wait(lck); + + while (count > 0){ + cv.wait(lck); + } } }