pub struct LiveTimer {
pub name: Ustr,
pub interval_ns: NonZeroU64,
pub start_time_ns: UnixNanos,
pub stop_time_ns: Option<UnixNanos>,
/* 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.
Fields§
§name: Ustr
The name of the timer.
interval_ns: NonZeroU64
The start time of the timer in UNIX nanoseconds.
start_time_ns: UnixNanos
The start time of the timer in UNIX nanoseconds.
stop_time_ns: Option<UnixNanos>
The optional stop time of the timer in UNIX nanoseconds.
Implementations§
Source§impl LiveTimer
impl LiveTimer
Sourcepub fn new(
name: &str,
interval_ns: u64,
start_time_ns: UnixNanos,
stop_time_ns: Option<UnixNanos>,
callback: TimeEventCallback,
heap: Arc<Mutex<BinaryHeap<TimeEvent>>>,
) -> Self
pub fn new( name: &str, interval_ns: u64, start_time_ns: UnixNanos, stop_time_ns: Option<UnixNanos>, callback: TimeEventCallback, heap: Arc<Mutex<BinaryHeap<TimeEvent>>>, ) -> 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.
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
Mutably borrows from an owned value. Read more
§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>
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