From d30cabffc36ed5069190269f900148d5facc65f3 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 26 Aug 2026 11:49:05 -0700 Subject: [PATCH] ts_time: fix documentation of the event refcounting invariant in Scheduler We could also remove that tricky invariant entirely by making events Clone, but at this point the invariant's easy enough to reason about when changing the scheduler. Signed-off-by: David Anderson Change-Id: Ic3e3c43d389b5b3a61ccb6e2f59895b86a6a6964 --- ts_time/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ts_time/src/lib.rs b/ts_time/src/lib.rs index aa759aa4..28ebf29a 100644 --- a/ts_time/src/lib.rs +++ b/ts_time/src/lib.rs @@ -79,8 +79,8 @@ pub struct Scheduler { // // Invariant: each FutureEvent is referenced from a few places only: one Arc in this Vec, // one Weak in the Handle for the event, and a temporary upgraded Arc during the execution of - // Handle's methods. This invariant is relied upon by SchedulerInner, which accounts for all - // these potential references prior to unwrapping Arc::get_mut and Arc::into_inner. + // Handle's Drop impl. This invariant is relied upon by Scheduler::dispatch, which accounts for + // all these potential references prior to unwrapping Arc::get_mut and Arc::into_inner. // Additional rogue references would invalidate this accounting and cause runtime panics. events: Arc>>>>, } @@ -158,7 +158,7 @@ impl Scheduler { let idx = Scheduler::partition_point(&events, now); let to_dispatch = events.split_off(idx); - // Invariant: at most 3 refs to the event exist (see doc on SchedulerInner struct). + // Invariant: at most 3 refs to the event exist (see doc on Scheduler struct). // We haven't upgraded the Handle's Weak, so that Arc doesn't exist. The iterator owns the // Arc that was formerly in self.events, and into_inner is not blocked by the existence of // the Handle's Weak. Thus, into_inner always succeeds.