| 24 | namespace { |
| 25 | |
| 26 | TEST(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 | |
| 50 | TEST(UnboundedThreadPool, MultipleBlockingThreads) { |
| 51 | UnboundedThreadPool pool(Env::Default(), "test"); |
nothing calls this directly
no test coverage detected