Do not start threads unnecesarily

This commit is contained in:
János Benjamin Antal 2023-04-19 11:30:54 +02:00
parent da7a557a6e
commit 6c48399338

View File

@ -515,10 +515,11 @@ LoadPartialConnectivityResult LoadPartialConnectivity(const std::filesystem::pat
} }
template <typename TFunc> template <typename TFunc>
void RecoverOnMultipleThreads(const size_t thread_count, const TFunc &func, const std::vector<BatchInfo> &batches) { void RecoverOnMultipleThreads(size_t thread_count, const TFunc &func, const std::vector<BatchInfo> &batches) {
utils::Synchronized<std::optional<RecoveryFailure>, utils::SpinLock> maybe_error{}; utils::Synchronized<std::optional<RecoveryFailure>, utils::SpinLock> maybe_error{};
{ {
std::atomic<uint64_t> batch_counter = 0; std::atomic<uint64_t> batch_counter = 0;
thread_count = std::min(thread_count, batches.size());
std::vector<std::jthread> threads; std::vector<std::jthread> threads;
threads.reserve(thread_count); threads.reserve(thread_count);