242
|
TEST_F(ThreadPoolTest, ThreadPoolRunsOnCreateThreadFunctionBeforeConsumingTasks) {
|
243
|
bool onCreateThreadCalled = false;
|
244
|
std::string taskThreadName;
|
245
|
ThreadPool::Options options;
|
246
|
options.threadNamePrefix = "mythread";
|
247
|
options.maxThreads = 1U;
|
248
|
options.onCreateThread = [&onCreateThreadCalled,
|
249
|
&taskThreadName](const std::string& threadName) {
|
250
|
onCreateThreadCalled = true;
|
251
|
taskThreadName = threadName;
|
252
|
};
|
253
|
|
254
|
auto& pool = makePool(options);
|
255
|
pool.startup();
|
256
|
unittest::Barrier barrier(2U);
|
257
|
ASSERT_OK(pool.schedule([&barrier] { barrier.countDownAndWait(); }));
|
258
|
barrier.countDownAndWait();
|
259
|
|
260
|
ASSERT_TRUE(onCreateThreadCalled);
|
261
|
ASSERT_EQUALS(options.threadNamePrefix + "0", taskThreadName);
|
262
|
}
|