Struct tor_rtmock::time::MockSleepProvider [−][src]
pub struct MockSleepProvider { /* fields omitted */ }Expand description
A dummy SleepProvider instance for testing.
The MockSleepProvider ignores the current time, and instead keeps
its own view of the current Instant and SystemTime. You
can advance them in-step by calling advance(), and you can simulate
jumps in the system clock by calling jump().
This is not for production use.
Implementations
Create a new MockSleepProvider, starting at a given wall-clock time.
Advance the simulated timeline forward by dur.
Calling this function will wake any pending futures as appropriate, and yield to the scheduler so they get a chance to run.
Limitations
This function advances time in one big step. We might instead want to advance in small steps and make sure that each step’s futures can get run before the ones scheduled to run after it.
Simulate a discontinuity in the system clock, by jumping to
new_wallclock.
Panics
Panics if we have already panicked while holding the lock on the internal timer state, and the lock is poisoned.
Trait Implementations
type SleepFuture = Sleeping
type SleepFuture = Sleeping
A future returned by SleepProvider::sleep()
Return a future that will be ready after duration has
elapsed. Read more
Signify that a test running under mock time shouldn’t advance time yet, with a given unique reason string. This is useful for making sure (mock) time doesn’t advance while things that might require some (real-world) time to complete do so, such as spawning a task on another thread. Read more
Signify that the reason to withhold time advancing provided in a call to block_advance no
longer exists, and it’s fine to move time forward if nothing else is blocking advances. Read more
Allow a test running under mock time to advance time by the provided duration, even if the
above block_advance API has been used. Read more
Return the SleepProvider’s view of the current wall-clock time. Read more
Auto Trait Implementations
impl RefUnwindSafe for MockSleepProvider
impl Send for MockSleepProvider
impl Sync for MockSleepProvider
impl Unpin for MockSleepProvider
impl UnwindSafe for MockSleepProvider
Blanket Implementations
Mutably borrows from an owned value. Read more
Pause until the wall-clock is at when or later, trying to
recover from clock jumps. Read more