20 #include "gtest/gtest.h" 42 auto cond = [
this,
n]() {
return count_ >=
n; };
82 EXPECT_LE(delay - slop, elapsed)
83 <<
"WaitForNotificationWithTimeout returned " << delay - elapsed
84 <<
" early (with " << slop <<
" slop), start time was " << start;
89 if (notify_before_waiting) {
96 std::vector<std::thread> workers;
98 workers.push_back(std::thread(&
RunWorker,
i, &ready_counter, notification,
102 if (!notify_before_waiting) {
107 EXPECT_EQ(0, done_counter.
Get());
118 for (std::thread& worker : workers) {
121 EXPECT_EQ(kNumThreads, ready_counter.
Get());
122 EXPECT_EQ(kNumThreads, done_counter.
Get());
125 TEST(NotificationTest, SanityTest) {
void WaitUntilGreaterOrEqual(int n)
bool HasBeenNotified() const
bool WaitForNotificationWithDeadline(absl::Time deadline) const
TEST(NotificationTest, SanityTest)
constexpr Duration Microseconds(int64_t n)
constexpr Duration Milliseconds(int64_t n)
bool WaitForNotificationWithTimeout(absl::Duration timeout) const
void WaitForNotification() const
static void BasicTests(bool notify_before_waiting, Notification *notification)
constexpr Duration Seconds(int64_t n)
constexpr int32_t kNumThreads
void Await(const Condition &cond)
static void RunWorker(int i, ThreadSafeCounter *ready_counter, Notification *notification, ThreadSafeCounter *done_counter)