diff --git a/src/dwarfsck_main.cpp b/src/dwarfsck_main.cpp index b5df8533..2bbe2a4a 100644 --- a/src/dwarfsck_main.cpp +++ b/src/dwarfsck_main.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -48,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -104,7 +104,7 @@ void do_checksum(logger& lgr, filesystem_v2& fs, iolayer const& iol, std::string const& algo, size_t num_workers) { LOG_PROXY(debug_logger_policy, lgr); - internal::worker_group wg{lgr, *iol.os, "checksum", num_workers}; + thread_pool pool{lgr, *iol.os, "checksum", num_workers}; std::mutex mx; fs.walk_data_order([&](auto const& de) { @@ -127,31 +127,34 @@ void do_checksum(logger& lgr, filesystem_v2& fs, iolayer const& iol, return; } - wg.add_job([&, de, iv, ranges = std::move(ranges)]() mutable { - checksum cs(algo); + pool.add_job( + [&, de, iv, + ranges = std::make_shared(std::move(ranges))]() { + checksum cs(algo); - for (auto& fut : ranges) { - try { - auto range = fut.get(); - cs.update(range.data(), range.size()); - } catch (std::exception const& e) { - LOG_ERROR << "error reading data from inode " << iv.inode_num() - << ": " << e.what(); - return; - } - } + for (auto& fut : *ranges) { + try { + auto range = fut.get(); + cs.update(range.data(), range.size()); + } catch (std::exception const& e) { + LOG_ERROR << "error reading data from inode " << iv.inode_num() + << ": " << e.what(); + return; + } + } - auto output = fmt::format("{} {}\n", cs.hexdigest(), de.unix_path()); + auto output = + fmt::format("{} {}\n", cs.hexdigest(), de.unix_path()); - { - std::lock_guard lock(mx); - iol.out << output; - } - }); + { + std::lock_guard lock(mx); + iol.out << output; + } + }); } }); - wg.wait(); + pool.wait(); } } // namespace