pub struct StopHandle { /* private fields */ }Expand description
Handle to stop a running scheduler.
Implementations§
Source§impl StopHandle
impl StopHandle
Sourcepub async fn stop(&self)
pub async fn stop(&self)
Stop the scheduler and join the capture thread. &self +
interior-mutable thread so a session host holding a shared
Arc<StopHandle> can stop it without sole ownership.
Idempotent — a second call (or drop after) sees thread
already taken and no-ops.
ASYNC on purpose — the wait must YIELD to the runtime, never
block it. The timing thread’s final flush block_ons
CadenceReporter::shutdown_flush, whose ack comes from the
reporter’s OWNER — a tokio task on the caller’s runtime. A
blocking wait here deadlocked a CURRENT-THREAD runtime three
ways: this (the only runtime) thread parked in recv(), the
timing thread parked awaiting the owner’s ack, and the owner
task unable to run on the parked runtime. Multi-thread runtimes
escaped via block_in_place + spare workers, which is why only
single-threaded harnesses hung. The yield-poll below lets
same-runtime tasks progress on every flavor; this is a
session-end one-shot, so the 2 ms poll cadence touches no hot
path.
Sourcepub fn cadence_reporter(&self) -> Option<&Arc<CadenceReporter>>
pub fn cadence_reporter(&self) -> Option<&Arc<CadenceReporter>>
Reference to the cadence reporter, if any.
Remains valid and queryable after the scheduler is stopped.
Sourcepub fn report_frame(&self, snapshot: &MetricSet)
pub fn report_frame(&self, snapshot: &MetricSet)
Deliver a frame to reporters asynchronously.
The frame is enqueued on a channel and processed by the scheduler thread on its next tick. This never blocks the caller — safe to call from tokio worker threads.