pub struct HeartbeatScheduler { /* private fields */ }Expand description
Manages heartbeat schedules for multiple agents.
Call [tick] with the elapsed wall-clock delta. Agents whose
accumulated elapsed time exceeds their configured interval will
be returned as needing a wake-up.
Implementations§
Source§impl HeartbeatScheduler
impl HeartbeatScheduler
Sourcepub fn register(&mut self, config: HeartbeatConfig)
pub fn register(&mut self, config: HeartbeatConfig)
Register an agent heartbeat. Replaces any existing entry.
Sourcepub fn unregister(&mut self, agent_id: &str) -> bool
pub fn unregister(&mut self, agent_id: &str) -> bool
Remove an agent from the scheduler. Returns true if it existed.
Sourcepub fn tick(&mut self, delta: Duration) -> Vec<HeartbeatTickResult>
pub fn tick(&mut self, delta: Duration) -> Vec<HeartbeatTickResult>
Advance all heartbeats by delta time.
Returns a list of agents that need to wake up (their interval has elapsed). Agents that are disabled are skipped.
Sourcepub fn phase(&self, agent_id: &str) -> Option<HeartbeatPhase>
pub fn phase(&self, agent_id: &str) -> Option<HeartbeatPhase>
Return the current phase of a given agent.
Sourcepub fn advance_phase(&mut self, agent_id: &str) -> Option<HeartbeatPhase>
pub fn advance_phase(&mut self, agent_id: &str) -> Option<HeartbeatPhase>
Advance a specific agent to its next phase.
Sourcepub fn tick_count(&self, agent_id: &str) -> Option<u64>
pub fn tick_count(&self, agent_id: &str) -> Option<u64>
Get the tick count for a given agent.
Trait Implementations§
Source§impl Debug for HeartbeatScheduler
impl Debug for HeartbeatScheduler
Auto Trait Implementations§
impl Freeze for HeartbeatScheduler
impl RefUnwindSafe for HeartbeatScheduler
impl Send for HeartbeatScheduler
impl Sync for HeartbeatScheduler
impl Unpin for HeartbeatScheduler
impl UnsafeUnpin for HeartbeatScheduler
impl UnwindSafe for HeartbeatScheduler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more