refactor(worker_group): use hardware concurrency when num_workers == 0

This commit is contained in:
Marcus Holland-Moritz 2023-12-19 19:58:42 +01:00
parent 366846caea
commit 138ed373b0

View File

@ -35,6 +35,7 @@
#include <folly/String.h>
#include <folly/portability/PThread.h>
#include <folly/portability/Windows.h>
#include <folly/system/HardwareConcurrency.h>
#include <folly/system/ThreadName.h>
#include "dwarfs/error.h"
@ -102,7 +103,7 @@ class basic_worker_group final : public worker_group::impl, private Policy {
, pending_(0)
, max_queue_len_(max_queue_len) {
if (num_workers < 1) {
DWARFS_THROW(runtime_error, "invalid number of worker threads");
num_workers = std::max(folly::hardware_concurrency(), 1u);
}
if (!group_name) {