Skip to content

Commit faa6c0f

Browse files
committed
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 <[email protected]>
1 parent abea096 commit faa6c0f

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/dmclock/src/dmclock_server.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -806,11 +806,7 @@ namespace crimson {
806806
RejectThreshold reject_threshold = 0;
807807

808808
double anticipation_timeout;
809-
#ifdef WITH_CRIMSON
810-
bool finishing;
811-
#else
812-
std::atomic_bool finishing;
813-
#endif
809+
814810
// every request creates a tick
815811
Counter tick = 0;
816812

@@ -853,7 +849,6 @@ namespace crimson {
853849
at_limit(get_or_default(at_limit_param, AtLimit::Reject)),
854850
reject_threshold(get_or_default(at_limit_param, RejectThreshold{0})),
855851
anticipation_timeout(_anticipation_timeout),
856-
finishing(false),
857852
idle_age(std::chrono::duration_cast<Duration>(_idle_age)),
858853
erase_age(std::chrono::duration_cast<Duration>(_erase_age)),
859854
check_time(std::chrono::duration_cast<Duration>(_check_time)),
@@ -869,12 +864,6 @@ namespace crimson {
869864
std::bind(&PriorityQueueBase::do_clean, this)));
870865
}
871866

872-
873-
~PriorityQueueBase() {
874-
finishing = true;
875-
}
876-
877-
878867
inline const ClientInfo* get_cli_info(ClientRec& client) const {
879868
if (is_dynamic_cli_info_f) {
880869
client.info = client_info_f(client.client);
@@ -1534,6 +1523,7 @@ namespace crimson {
15341523
CanHandleRequestFunc can_handle_f;
15351524
HandleRequestFunc handle_f;
15361525
// for handling timed scheduling
1526+
bool finishing = false;
15371527
std::mutex sched_ahead_mtx;
15381528
std::condition_variable sched_ahead_cv;
15391529
Time sched_ahead_when = TimeZero;
@@ -1591,9 +1581,9 @@ namespace crimson {
15911581

15921582

15931583
~PushPriorityQueue() {
1594-
this->finishing = true;
15951584
{
15961585
std::lock_guard<std::mutex> l(sched_ahead_mtx);
1586+
finishing = true;
15971587
sched_ahead_cv.notify_one();
15981588
}
15991589
sched_ahead_thd.join();

0 commit comments

Comments
 (0)