pub struct LiveTimer {
pub name: Ustr,
pub interval_ns: NonZeroU64,
pub start_time_ns: UnixNanos,
pub stop_time_ns: Option<UnixNanos>,
pub fire_immediately: bool,
/* private fields */
}Expand description
A live timer for use with a LiveClock.
LiveTimer triggers events at specified intervals in a real-time environment,
using Tokio’s async runtime to handle scheduling and execution.
§Threading
The timer runs on the runtime thread that created it and dispatches events across threads as needed.
Fields§
§name: UstrThe name of the timer.
interval_ns: NonZeroU64The start time of the timer in UNIX nanoseconds.
start_time_ns: UnixNanosThe start time of the timer in UNIX nanoseconds.
stop_time_ns: Option<UnixNanos>The optional stop time of the timer in UNIX nanoseconds.
fire_immediately: boolIf the timer should fire immediately at start time.
Implementations§
Source§impl LiveTimer
impl LiveTimer
Sourcepub fn new(
name: Ustr,
interval_ns: NonZeroU64,
start_time_ns: UnixNanos,
stop_time_ns: Option<UnixNanos>,
callback: TimeEventCallback,
fire_immediately: bool,
sender: Option<Arc<dyn TimeEventSender>>,
) -> Self
pub fn new( name: Ustr, interval_ns: NonZeroU64, start_time_ns: UnixNanos, stop_time_ns: Option<UnixNanos>, callback: TimeEventCallback, fire_immediately: bool, sender: Option<Arc<dyn TimeEventSender>>, ) -> Self
Sourcepub fn next_time_ns(&self) -> UnixNanos
pub fn next_time_ns(&self) -> UnixNanos
Returns the next time in UNIX nanoseconds when the timer will fire.
Provides the scheduled time for the next event based on the current state of the timer.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Returns whether the timer is expired.
An expired timer will not trigger any further events. A timer that has not been started is not expired.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LiveTimer
impl !RefUnwindSafe for LiveTimer
impl Send for LiveTimer
impl Sync for LiveTimer
impl Unpin for LiveTimer
impl !UnwindSafe for LiveTimer
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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