From faa6c0fcd7ac44edfd546031aedf3ecb93f413e4 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Fri, 8 Aug 2025 15:58:27 -0700 Subject: [PATCH] dmclock/src/dmclock_server: move PriorityQueueBase::finishing into PushPriorityQueue PriorityQueueBase::finishing is only used in PushPriorityQueue -- move there. Also, it wasn't actually necessary for finishing to be an atomic as long as ~PushPriorityQueue takes the lock before mutating it. The readers already hold the lock. Signed-off-by: Samuel Just --- src/dmclock/src/dmclock_server.h | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/dmclock/src/dmclock_server.h b/src/dmclock/src/dmclock_server.h index f27632bf34d..a8a168af2ca 100644 --- a/src/dmclock/src/dmclock_server.h +++ b/src/dmclock/src/dmclock_server.h @@ -806,11 +806,7 @@ namespace crimson { RejectThreshold reject_threshold = 0; double anticipation_timeout; -#ifdef WITH_CRIMSON - bool finishing; -#else - std::atomic_bool finishing; -#endif + // every request creates a tick Counter tick = 0; @@ -853,7 +849,6 @@ namespace crimson { at_limit(get_or_default(at_limit_param, AtLimit::Reject)), reject_threshold(get_or_default(at_limit_param, RejectThreshold{0})), anticipation_timeout(_anticipation_timeout), - finishing(false), idle_age(std::chrono::duration_cast(_idle_age)), erase_age(std::chrono::duration_cast(_erase_age)), check_time(std::chrono::duration_cast(_check_time)), @@ -869,12 +864,6 @@ namespace crimson { std::bind(&PriorityQueueBase::do_clean, this))); } - - ~PriorityQueueBase() { - finishing = true; - } - - inline const ClientInfo* get_cli_info(ClientRec& client) const { if (is_dynamic_cli_info_f) { client.info = client_info_f(client.client); @@ -1534,6 +1523,7 @@ namespace crimson { CanHandleRequestFunc can_handle_f; HandleRequestFunc handle_f; // for handling timed scheduling + bool finishing = false; std::mutex sched_ahead_mtx; std::condition_variable sched_ahead_cv; Time sched_ahead_when = TimeZero; @@ -1591,9 +1581,9 @@ namespace crimson { ~PushPriorityQueue() { - this->finishing = true; { std::lock_guard l(sched_ahead_mtx); + finishing = true; sched_ahead_cv.notify_one(); } sched_ahead_thd.join(); -- 2.39.5