[][src]Struct pausable_clock::PausableClock

pub struct PausableClock { /* fields omitted */ }

Source of time information that can be paused and resumed. At its heart it is a reference instant in real time, a record of elapsed time, and an atomic state stored in a u64

Implementations

impl PausableClock[src]

pub fn new(elapsed_time: Duration, paused: bool) -> PausableClock[src]

Create a new pausable clock with the given pause state and the given elapsed time

pub fn now_std(&self) -> Instant[src]

Get the current time according to this clock as a std instant

pub fn now(&self) -> PausableInstant[src]

Get the current time according to the clock

pub fn pause(&self) -> bool[src]

Pause the pausable clock. This function will set the pause state to pausing, then to paused. This ensures that no times will be read in the time between when now is read and when the pause state is set that is greater than the paused time.

Note. This method will block synchronously if there are unpausable tasks being run.

True will be returned for a successful pause (meaning the clock wasn't already paused), and false will be returned if the clock was paused when this method was called.

pub fn resume(&self) -> bool[src]

Resume the pausable clock. This function will set the pause state to resuming, then to resumed.

Note. This method will block synchronously if there are unresumable tasks being run.

True will be returned for a successful resume (meaning the clock wasn't already resumed), and false will be returned if the clock was resumed when this method was called.

pub fn is_paused(&self) -> bool[src]

Check to see if the clock is paused using relaxed atomic ordering

pub fn is_pausing(&self) -> bool[src]

Check to see if the clock is pausing using relaxed atomic ordering. Note that a clock that is paused will not be pausing

pub fn is_paused_or_pausing(&self) -> bool[src]

Check to see if the clock is paused or pausing using relaxed atomic ordering

pub fn wait_for_resume(&self)[src]

Block the current thread until the clock resumes. If the clock is not paused when this method is called, the method will return without blocking

pub fn wait_for_pause(&self)[src]

Block the current thread until the clock pauses. If the clock is paused when this method is called, the method will return without blocking

pub fn run_unpausable<F, T>(&self, action: F) -> T where
    F: FnOnce() -> T, 
[src]

This method provides a way to run in coordination with the pause functionality of the clock. A task run with this method will prevent the clock from being paused, and will not be run while the clock is paused

pub fn run_if_resumed<F, T>(&self, action: F) -> Option<T> where
    F: FnOnce() -> T, 
[src]

This method provides a way to run in coordination with the pause functionality of the clock. A task run with this method will prevent the clock from being paused, but will not be run if the clock is paused. The turn will contain the result of evaluation of the task if the task is run, and will be None if the task was not run (meaning the clock was paused)

pub fn run_unresumable<F, T>(&self, action: F) -> T where
    F: FnOnce() -> T, 
[src]

This method provides a way to run in coordination with the resume functionality of the clock. A task run with this method will prevent the clock from being resumed, and will not be run while the clock is resumed

pub fn run_if_paused<F, T>(&self, action: F) -> Option<T> where
    F: FnOnce() -> T, 
[src]

This method provides a way to run in coordination with the resume functionality of the clock. A task run with this method will prevent the clock from being resumed, but will not be run if the clock is not already paused. The turn will contain the result of evaluation of the task if the task is run, and will be None if the task was not run (meaning the clock was running)

pub fn is_paused_ordered(&self, ordering: Ordering) -> bool[src]

Check to see if the clock is paused using the given atomic ordering

pub fn is_pausing_ordered(&self, ordering: Ordering) -> bool[src]

Check to see if the clock is pausing using the given atomic ordering. Note that a clock that is paused will not be pausing

pub fn is_paused_or_pausing_ordered(&self, ordering: Ordering) -> bool[src]

Check to see if the clock is paused or pausing using the given atomic ordering

pub fn is_resumed_or_resuming_ordered(&self, ordering: Ordering) -> bool[src]

Check to see if the clock is resumed or resuming using the given atomic ordering

Trait Implementations

impl Debug for PausableClock[src]

impl Default for PausableClock[src]

The default pausable clock is one that is (more or less) identical to real time: Not paused and starting with zero starting offset

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.