Struct diem_time_service::mock::MockTimeService[][src]

pub struct MockTimeService { /* fields omitted */ }
Expand description

A TimeService that simulates time and allows for fine-grained control over advancing time and waking up sleeping tasks.

Auto Advance

MockTimeService has the option to auto advance time when new Sleeps are crated. When we’re auto advancing, new Sleeps are immediately resolved and the simulation time is advanced to the wait deadline. New Sleeps whose deadlines are after the auto advance deadline will be pending and must be manually woken by the MockTimeService::advance_{..} methods.

Implementations

Create a new MockTimeService with no auto advance. Time will only advance by manually calling the MockTimeService::advance_{..} methods.

Create a new MockTimeService that will auto advance forever.

Create a new MockTimeService that will auto advance until the simulation time passes deadline.

Return the number of pending Sleep waiters.

Advance time to the next pending waiter, wake it up, and return the wake time, or None if there are no waiters.

Advance time by duration and wake any pending waiters whose sleep has expired. Return the number of waiters that we woke up.

Advance time by duration seconds. See advance.

Advance time by duration milliseconds. See advance.

Advance time to the next pending waiter, wake it up, and return the wake time, or None if there are no waiters.

Yields to the executor to run any freshly awoken tasks (which might also create more Sleep futures).

Advance time by duration and wake any pending waiters whose sleep has expired. Return the number of waiters that we woke up.

Yields to the executor to run any freshly awoken tasks (which might also create more Sleep futures).

Advance time by duration seconds. See advance_async.

Advance time by duration milliseconds. See advance_async.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Query a monotonically nondecreasing clock. Returns an opaque type that can only be compared to other Instants, i.e., this is a monotonic relative time whereas now_unix_time is a non-monotonic absolute time. Read more

Query the current unix timestamp as a Duration. Read more

Return a Future that waits until duration has passed. Read more

Blocks the current thread until duration time has passed.

Query the current unix timestamp in seconds. Read more

Return a Future that waits until the deadline. Read more

Creates a new Interval that yields with interval of period. The first tick completes immediately. An interval will tick indefinitely. Read more

Creates a new Interval that yields with interval of period. The first tick completes after the start deadline. An interval will tick indefinitely. Read more

Require a Future to complete before the specified duration has elapsed. Read more

Require a Future to complete before the deadline. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.