pub struct TimerWithThread<I, O>{ /* private fields */ }Expand description
A timer implementation that uses its own thread.
This instance is essentially the owning handle. Non-owning references can be created with [TimerWithThread::timer_ref] and are always cloneable.
Implementations§
Source§impl<I, O> TimerWithThread<I, O>
impl<I, O> TimerWithThread<I, O>
Sourcepub fn new(
max_wait_time: Duration,
) -> Result<TimerWithThread<I, O>, ThreadTimerError>
pub fn new( max_wait_time: Duration, ) -> Result<TimerWithThread<I, O>, ThreadTimerError>
Create a new timer with its own thread.
max_wait_time is the maximum time we wait until we check the clock again,
in case it jumped (e.g. after sleep or due to a timezone change).
Sourcepub fn new_with_clock<C>(
clock: C,
max_wait_time: Duration,
) -> Result<TimerWithThread<I, O>, ThreadTimerError>where
C: Clock,
pub fn new_with_clock<C>(
clock: C,
max_wait_time: Duration,
) -> Result<TimerWithThread<I, O>, ThreadTimerError>where
C: Clock,
Create a new timer with its own thread using a custom clock.
This is mostly meant for testing, but can also be used to supply other clock sources than [SystemTime].
max_wait_time is the maximum time we wait until we check the clock again,
in case it jumped (e.g. after sleep or due to a timezone change).
Sourcepub fn shutdown(self) -> Result<(), ThreadTimerError>
pub fn shutdown(self) -> Result<(), ThreadTimerError>
Shut this timer down and wait for the thread to join.
Sourcepub fn shutdown_async(&self) -> Result<(), ThreadTimerError>
pub fn shutdown_async(&self) -> Result<(), ThreadTimerError>
Same as shutdown, but doesn’t wait for the thread to join.
Source§impl TimerWithThread<Uuid, ClosureState<Uuid>>
impl TimerWithThread<Uuid, ClosureState<Uuid>>
Sourcepub fn for_uuid_closures(
max_wait_time: Duration,
) -> Result<Self, ThreadTimerError>
Available on crate feature uuid only.
pub fn for_uuid_closures( max_wait_time: Duration, ) -> Result<Self, ThreadTimerError>
uuid only.Create a UUID-based timer using closure states.