36 std::condition_variable b1DoneCond;
37 std::condition_variable b2DoneCond;
38 std::atomic<uint32_t> b1TrueSeen(0);
39 std::atomic<uint32_t> b1Passed(0);
40 std::atomic<uint32_t> b2TrueSeen(0);
41 std::atomic<uint32_t> b2Passed(0);
43 Barrier barrier(numThreads + 1);
45 std::vector<std::thread>
threads;
46 threads.reserve(numThreads);
48 threads.emplace_back([&]() {
51 std::unique_lock<std::mutex>
lock(mutex);
53 if (++b1Passed == numThreads) {
54 b1DoneCond.notify_one();
56 return barrier.wait();
59 std::unique_lock<std::mutex>
lock(mutex);
61 if (++b2Passed == numThreads) {
62 b2DoneCond.notify_one();
70 std::this_thread::sleep_for(std::chrono::milliseconds(50));
74 b1TrueSeen += barrier.wait().get();
77 std::unique_lock<std::mutex>
lock(mutex);
78 while (b1Passed != numThreads) {
79 b1DoneCond.wait(
lock);
85 std::this_thread::sleep_for(std::chrono::milliseconds(50));
89 b2TrueSeen += barrier.wait().get();
92 std::unique_lock<std::mutex>
lock(mutex);
93 while (b2Passed != numThreads) {
94 b2DoneCond.wait(
lock);
99 for (
auto&
t : threads) {
#define EXPECT_EQ(val1, val2)
std::vector< std::thread::id > threads
auto lock(SynchronizedLocker...lockersIn) -> std::tuple< typename SynchronizedLocker::LockedPtr... >