mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-14 06:48:39 -04:00
refactor(worker_group): use hardware concurrency when num_workers == 0
This commit is contained in:
parent
366846caea
commit
138ed373b0
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user