diff --git a/include/dwarfs/util.h b/include/dwarfs/util.h index 4c809cbd..287d960b 100644 --- a/include/dwarfs/util.h +++ b/include/dwarfs/util.h @@ -82,4 +82,6 @@ void ensure_binary_mode(std::ostream& os); std::string exception_str(std::exception const& e); std::string exception_str(std::exception_ptr const& e); +unsigned int hardware_concurrency() noexcept; + } // namespace dwarfs diff --git a/src/dwarfs/block_cache.cpp b/src/dwarfs/block_cache.cpp index a1c32b2b..90f177c6 100644 --- a/src/dwarfs/block_cache.cpp +++ b/src/dwarfs/block_cache.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include @@ -51,6 +50,7 @@ #include #include #include +#include namespace dwarfs { @@ -229,7 +229,7 @@ class block_cache_ final : public block_cache::impl { wg_ = internal::worker_group(lgr, os_, "blkcache", std::max(options.num_workers > 0 ? options.num_workers - : folly::hardware_concurrency(), + : hardware_concurrency(), static_cast(1))); } } diff --git a/src/dwarfs/internal/worker_group.cpp b/src/dwarfs/internal/worker_group.cpp index 04e7cd12..8e0ad9da 100644 --- a/src/dwarfs/internal/worker_group.cpp +++ b/src/dwarfs/internal/worker_group.cpp @@ -38,7 +38,6 @@ #include #include -#include #include #include @@ -65,7 +64,7 @@ class basic_worker_group final : public worker_group::impl, private Policy { , pending_(0) , max_queue_len_(max_queue_len) { if (num_workers < 1) { - num_workers = std::max(folly::hardware_concurrency(), 1u); + num_workers = std::max(hardware_concurrency(), 1u); } if (!group_name) { diff --git a/src/dwarfs/util.cpp b/src/dwarfs/util.cpp index 04e98576..a80793f1 100644 --- a/src/dwarfs/util.cpp +++ b/src/dwarfs/util.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -386,4 +387,8 @@ std::string exception_str(std::exception_ptr const& e) { return folly::exceptionStr(e).toStdString(); } +unsigned int hardware_concurrency() noexcept { + return folly::hardware_concurrency(); +} + } // namespace dwarfs diff --git a/src/dwarfsck_main.cpp b/src/dwarfsck_main.cpp index e724fb99..e8105e08 100644 --- a/src/dwarfsck_main.cpp +++ b/src/dwarfsck_main.cpp @@ -35,7 +35,6 @@ #endif #include -#include #include #include @@ -161,7 +160,7 @@ void do_checksum(logger& lgr, filesystem_v2& fs, iolayer const& iol, } // namespace int dwarfsck_main(int argc, sys_char** argv, iolayer const& iol) { - const size_t num_cpu = std::max(folly::hardware_concurrency(), 1u); + const size_t num_cpu = std::max(hardware_concurrency(), 1u); auto algo_list = checksum::available_algorithms(); auto checksum_desc = fmt::format("print checksums for all files ({})", diff --git a/src/mkdwarfs_main.cpp b/src/mkdwarfs_main.cpp index e3ab81b4..00827301 100644 --- a/src/mkdwarfs_main.cpp +++ b/src/mkdwarfs_main.cpp @@ -51,7 +51,6 @@ #include #include #include -#include #include #if FMT_VERSION >= 110000 @@ -374,7 +373,7 @@ void validate(boost::any& v, std::vector const& values, int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) { using namespace std::chrono_literals; - const size_t num_cpu = std::max(folly::hardware_concurrency(), 1u); + const size_t num_cpu = std::max(hardware_concurrency(), 1u); static constexpr size_t const kDefaultMaxActiveBlocks{1}; static constexpr size_t const kDefaultBloomFilterSize{4};