From: David Goldblatt Date: Fri, 9 Dec 2016 01:20:46 +0000 (-0800) Subject: Fix SimpleBarrier X-Git-Tag: v2016.12.12.00~5 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=43d3a315bbd54cb187021897b566ffb53290a44b Fix SimpleBarrier Summary: Do the barrier completion test in a loop. (std::condition_variable has pthreads-style spurious wakeups). (Sorry for missing this in review). Reviewed By: djwatson Differential Revision: D4302035 fbshipit-source-id: 3322d6a0ffba8c47c46bafb1d88034e1a0a9c652 --- diff --git a/folly/test/SmallLocksBenchmark.cpp b/folly/test/SmallLocksBenchmark.cpp index 9b86adf3..ca69b1a0 100644 --- a/folly/test/SmallLocksBenchmark.cpp +++ b/folly/test/SmallLocksBenchmark.cpp @@ -51,7 +51,7 @@ struct SimpleBarrier { if (++num_ == count_) { cv_.notify_all(); } else { - cv_.wait(lockHeld); + cv_.wait(lockHeld, [&]() { return num_ >= count_; }); } }