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

Function TEST

tensorflow/core/kernels/data/unbounded_thread_pool_test.cc:26–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24namespace {
25
26TEST(UnboundedThreadPool, ConcurrentThreadCreation) {
27 UnboundedThreadPool pool(Env::Default(), "test");
28 auto thread_factory = pool.get_thread_factory();
29
30 // Create ten threads that each create ten threads that update a variable, and
31 // ensure that they all run to completion.
32 std::vector<std::unique_ptr<Thread>> threads;
33 const int kNumThreadsToCreate = 10;
34 std::atomic<int> i(0);
35 for (int j = 0; j < kNumThreadsToCreate; ++j) {
36 threads.push_back(thread_factory->StartThread("", [&i, thread_factory]() {
37 std::vector<std::unique_ptr<Thread>> nested_threads;
38 for (int k = 0; k < kNumThreadsToCreate; ++k) {
39 nested_threads.push_back(
40 thread_factory->StartThread("", [&i]() { ++i; }));
41 }
42 nested_threads.clear();
43 }));
44 }
45 threads.clear();
46
47 EXPECT_EQ(i, kNumThreadsToCreate * kNumThreadsToCreate);
48}
49
50TEST(UnboundedThreadPool, MultipleBlockingThreads) {
51 UnboundedThreadPool pool(Env::Default(), "test");

Callers

nothing calls this directly

Calls 9

DefaultFunction · 0.85
get_thread_factoryMethod · 0.80
push_backMethod · 0.45
StartThreadMethod · 0.45
clearMethod · 0.45
DecrementCountMethod · 0.45
WaitForNotificationMethod · 0.45
WaitMethod · 0.45
NotifyMethod · 0.45

Tested by

no test coverage detected