pub struct InactiveClock(/* private fields */);Expand description
An inactive clock that must be activated before time operations can be performed.
This type represents a clock in an inactive state that cannot perform any time-related operations until activated. It can be safely cloned and moved across threads, making it suitable for initialization in multi-threaded environments.
To begin using the clock, call InactiveClock::activate to get a working Clock instance and
its associated ClockDriver. The driver is responsible for advancing timers and must
be called periodically by the runtime.
§Examples
use tick::runtime::InactiveClock;
let inactive = InactiveClock::default();
let (clock, driver) = inactive.activate();
// Use the clock for time operations
let now = clock.instant();
// Driver must be advanced periodically (typically by the runtime)
// driver.advance_timers();§Thread-per-core runtimes
Thread-per-core runtimes can activate separate clock instances per thread by cloning
the InactiveClock before activation. This eliminates lock contention and improves
performance.
Implementations§
Source§impl InactiveClock
impl InactiveClock
Sourcepub fn activate(self) -> (Clock, ClockDriver)
pub fn activate(self) -> (Clock, ClockDriver)
Activates the clock for time operations.
Consumes this inactive clock and returns a working Clock instance along with
its ClockDriver. The driver must be called periodically to advance timers.
§Returns
A tuple containing:
Clock- The activated clock instance for time operationsClockDriver- Driver that advances timers (must be polled by caller)
Trait Implementations§
Source§impl Clone for InactiveClock
impl Clone for InactiveClock
Source§fn clone(&self) -> InactiveClock
fn clone(&self) -> InactiveClock
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InactiveClock
impl Debug for InactiveClock
Source§impl Default for InactiveClock
impl Default for InactiveClock
Source§fn default() -> InactiveClock
fn default() -> InactiveClock
Source§impl From<ClockControl> for InactiveClock
Available on crate features test-util only.
impl From<ClockControl> for InactiveClock
test-util only.