Skip to main content

WaitEffects

Trait WaitEffects 

Source
pub trait WaitEffects {
    // Required methods
    fn lock_present(&mut self) -> Result<bool, String>;
    fn gather(&mut self) -> Result<Option<Evidence>, String>;
    fn sleep(&mut self, ms: u64);
    fn random(&mut self) -> f64;
    fn now_ms(&mut self) -> f64;
    fn report(&mut self, line: &str);
}
Expand description

What: The side effects of a wait, injected so tests can drive a fake clock and fake holders. Why: The host implementation reads /proc, sleeps and writes standard error; tests script each step.

In TS you’d write (pseudocode):

type IndexLockWaitEffects = { gather; sleep; random; report; now };

Required Methods§

Source

fn lock_present(&mut self) -> Result<bool, String>

Whether the lock currently exists (the attempt).

Source

fn gather(&mut self) -> Result<Option<Evidence>, String>

This attempt’s evidence, or nothing when the lock was released meanwhile.

Source

fn sleep(&mut self, ms: u64)

Sleeps for ms milliseconds.

Source

fn random(&mut self) -> f64

A uniform value in [0, 1).

Source

fn now_ms(&mut self) -> f64

The current time in milliseconds.

Source

fn report(&mut self, line: &str)

Writes one line of diagnostics to standard error.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§