Do not create extra thread in PipelineExecutor if num_threads is 1.

This commit is contained in:
Nikolai Kochetov 2020-01-01 14:18:24 +03:00
parent 3f35d143b3
commit faf118fb15

View File

@ -720,6 +720,9 @@ void PipelineExecutor::executeImpl(size_t num_threads)
} }
} }
if (num_threads > 1)
{
for (size_t i = 0; i < num_threads; ++i) for (size_t i = 0; i < num_threads; ++i)
{ {
threads.emplace_back([this, thread_group, thread_num = i, num_threads] threads.emplace_back([this, thread_group, thread_num = i, num_threads]
@ -743,6 +746,9 @@ void PipelineExecutor::executeImpl(size_t num_threads)
for (auto & thread : threads) for (auto & thread : threads)
if (thread.joinable()) if (thread.joinable())
thread.join(); thread.join();
}
else
executeSingleThread(0, num_threads);
finished_flag = true; finished_flag = true;
} }