From 371606cde0136c248d2eaf411b60d4a4a7520317 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Thu, 12 May 2022 12:25:46 -0300 Subject: [PATCH] Eliminate useless unordered_set I don't know what this set was originally meant to be doing, but it currently does nothing (except adding overhead). The comment says it "owns" the instances but that isn't really true; the instances effectively already manage themselves as they pass the pointer through the communications between proxy and workers. --- oxenmq/jobs.cpp | 3 --- oxenmq/oxenmq.h | 2 -- oxenmq/worker.cpp | 1 - 3 files changed, 6 deletions(-) diff --git a/oxenmq/jobs.cpp b/oxenmq/jobs.cpp index 683055f..b3065ee 100644 --- a/oxenmq/jobs.cpp +++ b/oxenmq/jobs.cpp @@ -5,7 +5,6 @@ namespace oxenmq { void OxenMQ::proxy_batch(detail::Batch* batch) { - batches.insert(batch); const auto [jobs, tagged_threads] = batch->size(); OMQ_TRACE("proxy queuing batch job with ", jobs, " jobs", tagged_threads ? " (job uses tagged thread(s))" : ""); if (!tagged_threads) { @@ -37,7 +36,6 @@ void OxenMQ::job(std::function f, std::optional thread) void OxenMQ::proxy_schedule_reply_job(std::function f) { auto* j = new Job(std::move(f)); reply_jobs.emplace_back(static_cast(j), 0); - batches.insert(j); proxy_skip_one_poll = true; } @@ -113,7 +111,6 @@ void OxenMQ::_queue_timer_job(int timer_id) { } else { b = new Job(func, thread); } - batches.insert(b); OMQ_TRACE("b: ", b->size().first, ", ", b->size().second, "; thread = ", thread); assert(b->size() == std::make_pair(size_t{1}, thread > 0)); auto& queue = thread > 0 diff --git a/oxenmq/oxenmq.h b/oxenmq/oxenmq.h index 4547f43..1b47c33 100644 --- a/oxenmq/oxenmq.h +++ b/oxenmq/oxenmq.h @@ -576,8 +576,6 @@ private: /// weaker (i.e. it cannot reconnect to the SN if the connection is no longer open). void proxy_reply(oxenc::bt_dict_consumer data); - /// Currently active batch/reply jobs; this is the container that owns the Batch instances - std::unordered_set batches; /// Individual batch jobs waiting to run; .second is the 0-n batch number or -1 for the /// completion job using batch_job = std::pair; diff --git a/oxenmq/worker.cpp b/oxenmq/worker.cpp index 222e68a..abab766 100644 --- a/oxenmq/worker.cpp +++ b/oxenmq/worker.cpp @@ -247,7 +247,6 @@ void OxenMQ::proxy_worker_message(std::vector& parts) { } if (clear_job) { - batches.erase(batch); delete batch; run.to_run = static_cast(nullptr); }