Fix SimpleBarrier
authorDavid Goldblatt <davidgoldblatt@fb.com>
Fri, 9 Dec 2016 01:20:46 +0000 (17:20 -0800)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Fri, 9 Dec 2016 18:03:50 +0000 (10:03 -0800)
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

folly/test/SmallLocksBenchmark.cpp

index 9b86adf3b57de816e38f492170eba24cddaf35ab..ca69b1a06b8f5119c9cffc4a31fae852b70022f7 100644 (file)
@@ -51,7 +51,7 @@ struct SimpleBarrier {
     if (++num_ == count_) {
       cv_.notify_all();
     } else {
-      cv_.wait(lockHeld);
+      cv_.wait(lockHeld, [&]() { return num_ >= count_; });
     }
   }