20 #include "gtest/gtest.h" 27 void PauseAndDecreaseCounter(BlockingCounter*
counter,
int* done) {
30 counter->DecrementCount();
33 TEST(BlockingCounterTest, BasicFunctionality) {
38 const int num_workers = 10;
39 BlockingCounter
counter(num_workers);
41 std::vector<std::thread> workers;
42 std::vector<int> done(num_workers, 0);
46 workers.reserve(num_workers);
47 for (
int k = 0; k < num_workers; k++) {
49 [&counter, &done, k] { PauseAndDecreaseCounter(&counter, &done[k]); });
56 for (
int k = 0; k < num_workers; k++) {
57 EXPECT_EQ(1, done[k]);
60 for (std::thread& w : workers) {
void SleepFor(absl::Duration duration)
TEST(NotificationTest, SanityTest)
constexpr Duration Seconds(int64_t n)