From: Samuel Just Date: Sat, 17 Sep 2022 02:42:49 +0000 (+0000) Subject: ceph_dedup_tool: SampleDedupWorkerThread can simply inherit from Thread X-Git-Tag: v18.0.0~6^2~10 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=da52fb63f256a69afe14d70c4a55b747ee590bb7;p=ceph-ci.git ceph_dedup_tool: SampleDedupWorkerThread can simply inherit from Thread SampleDedupWorkerThread didn't actually use any of the facilities on CrawlerThread and indeed left several of them uninitialized. Also allows us to remove the CrawlerThread constructor which left several members uninitialized. Signed-off-by: Samuel Just --- diff --git a/src/tools/ceph_dedup_tool.cc b/src/tools/ceph_dedup_tool.cc index 4075d562b44..c97b46e8813 100644 --- a/src/tools/ceph_dedup_tool.cc +++ b/src/tools/ceph_dedup_tool.cc @@ -232,7 +232,6 @@ public: io_ctx(io_ctx), n(n), m(m), begin(begin), end(end), report_period(report_period), total_objects(num_objects), max_read_size(max_read_size) {} - CrawlerThread() { } void signal(int signum) { std::lock_guard l{m_lock}; @@ -537,7 +536,7 @@ void ChunkScrub::chunk_scrub_common() using AioCompRef = unique_ptr; -class SampleDedupWorkerThread : public CrawlerThread +class SampleDedupWorkerThread : public Thread { public: struct chunk_t { @@ -1670,15 +1669,10 @@ int make_crawling_daemon(const po::variables_map &opts) return -EINVAL; } - bool debug = false; - if (opts.count("debug")) { - debug = true; - } - - estimate_threads.clear(); SampleDedupWorkerThread::SampleDedupGlobal sample_dedup_global( chunk_dedup_threshold, sampling_ratio); + std::list threads; for (unsigned i = 0; i < max_thread; i++) { cout << " add thread.. " << std::endl; ObjectCursor shard_start; @@ -1691,23 +1685,20 @@ int make_crawling_daemon(const po::variables_map &opts) &shard_start, &shard_end); - unique_ptr ptr ( - new SampleDedupWorkerThread( - io_ctx, - chunk_io_ctx, - shard_start, - shard_end, - chunk_size, - fp_algo, - chunk_algo, - sample_dedup_global)); - ptr->set_debug(debug); - ptr->create("sample_dedup"); - estimate_threads.push_back(move(ptr)); + threads.emplace_back( + io_ctx, + chunk_io_ctx, + shard_start, + shard_end, + chunk_size, + fp_algo, + chunk_algo, + sample_dedup_global); + threads.back().create("sample_dedup"); } - for (auto &p : estimate_threads) { - p->join(); + for (auto &p : threads) { + p.join(); } if (loop) { sleep(wakeup_period);