MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST

Function TEST

tensorflow/core/lib/core/notification_test.cc:26–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24namespace {
25
26TEST(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
54TEST(NotificationTest, TestMultipleThreadsWaitingOnNotification) {
55 const int num_closures = 4;

Callers

nothing calls this directly

Calls 6

DefaultFunction · 0.85
ScheduleMethod · 0.45
NotifyMethod · 0.45
WaitForNotificationMethod · 0.45
SleepForMicrosecondsMethod · 0.45

Tested by

no test coverage detected