pub struct Clock {
pub shared_state: Rc<ClockState>,
/* private fields */
}Expand description
State representing a clock.
Fields§
Implementations§
Source§impl Clock
impl Clock
Sourcepub fn time_now_ns(&self) -> f64
pub fn time_now_ns(&self) -> f64
Returns the current time in ns.
Sourcepub fn time_of_next(&self) -> f64
pub fn time_of_next(&self) -> f64
Returns the time in ns of the next event registered with this clock.
Sourcepub fn to_ns(&self, clock_time: &ClockTick) -> f64
pub fn to_ns(&self, clock_time: &ClockTick) -> f64
Convert the given ClockTick to a time in ns for this clock.
Sourcepub fn wait_ticks(&self, ticks: u64) -> ClockDelay ⓘ
pub fn wait_ticks(&self, ticks: u64) -> ClockDelay ⓘ
Returns a ClockDelay future which must be awaited to delay the
specified number of ticks.
Sourcepub fn wait_ticks_or_exit(&self, ticks: u64) -> ClockDelay ⓘ
pub fn wait_ticks_or_exit(&self, ticks: u64) -> ClockDelay ⓘ
Returns a ClockDelay future which must be awaited to delay the
specified number of ticks. However, if the remainder of the simulation
completes then this future is allowed to not complete. This allows the
user to create tasks that can run continuously as long as the rest of
the simulation continues to run.
pub fn next_tick_and_phase(&self, phase: u32) -> ClockDelay ⓘ
pub fn wait_phase(&self, phase: u32) -> ClockDelay ⓘ
Sourcepub fn advance_to(&self, time_ns: f64)
pub fn advance_to(&self, time_ns: f64)
Advance to the next tick after the specified time.
Trait Implementations§
Source§impl Ord for Clock
impl Ord for Clock
Source§impl PartialEq for Clock
The comparison operators for Clocks - use the next pending Waker time.
impl PartialEq for Clock
The comparison operators for Clocks - use the next pending Waker time.
Source§impl PartialOrd for Clock
impl PartialOrd for Clock
impl Eq for Clock
Auto Trait Implementations§
impl Freeze for Clock
impl !RefUnwindSafe for Clock
impl !Send for Clock
impl !Sync for Clock
impl Unpin for Clock
impl !UnwindSafe for Clock
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