| 24 | namespace { |
| 25 | |
| 26 | TEST(NotificationTest, TestSingleNotification) { |
| 27 | thread::ThreadPool* thread_pool = |
| 28 | new thread::ThreadPool(Env::Default(), "test", 1); |
| 29 | |
| 30 | int counter = 0; |
| 31 | Notification start; |
| 32 | Notification proceed; |
| 33 | thread_pool->Schedule([&start, &proceed, &counter] { |
| 34 | start.Notify(); |
| 35 | proceed.WaitForNotification(); |
| 36 | ++counter; |
| 37 | }); |
| 38 | |
| 39 | // Wait for the thread to start |
| 40 | start.WaitForNotification(); |
| 41 | |
| 42 | // The thread should be waiting for the 'proceed' notification. |
| 43 | EXPECT_EQ(0, counter); |
| 44 | |
| 45 | // Unblock the thread |
| 46 | proceed.Notify(); |
| 47 | |
| 48 | delete thread_pool; // Wait for closure to finish. |
| 49 | |
| 50 | // Verify the counter has been incremented |
| 51 | EXPECT_EQ(1, counter); |
| 52 | } |
| 53 | |
| 54 | TEST(NotificationTest, TestMultipleThreadsWaitingOnNotification) { |
| 55 | const int num_closures = 4; |
nothing calls this directly
no test coverage detected