diff --git a/src/engine/tasks.cpp b/src/engine/tasks.cpp index f9b4db61f5..72e32fc3e1 100644 --- a/src/engine/tasks.cpp +++ b/src/engine/tasks.cpp @@ -222,8 +222,15 @@ inline executor::implementation::implementation(unsigned parallelism) runners.reserve(parallelism); for (; parallelism > 0; --parallelism) { - running_count += 1; - runners.emplace_back([this]() { runner(); }); + try + { + runners.emplace_back([this]() { runner(); }); + running_count += 1; + } + catch (const std::system_error & e) + { + err_printf("Task execution error: %s"); + } } #endif } @@ -348,7 +355,8 @@ executor::~executor() { i->stop(); } std::shared_ptr executor::make(int parallelism) { - auto result = std::make_shared(*this, get_parallelism(parallelism)); + auto result = std::make_shared(*this, + std::min(unsigned(i->runners.size()), get_parallelism(parallelism))); i->push_group(result); return result; }