Crate atomic_interval

source ·
Expand description

A thread-safe tiny implementation of a lock-free interval/timer structure.

§Example

use atomic_interval::AtomicIntervalLight;
use std::time::Duration;
use std::time::Instant;

let period = Duration::from_secs(1);
let atomic_interval = AtomicIntervalLight::new(period);

let time_start = Instant::now();
let elapsed = loop {
    if atomic_interval.is_ticked() {
        break time_start.elapsed();
    }
};

println!("Elapsed: {:?}", elapsed);

§Memory Ordering

Like other standard atomic types, AtomicInterval requires specifying how the memory accesses have to be synchronized.

For more information see the nomicon.

§AtomicIntervalLight

AtomicIntervalLight is an AtomicInterval’s variant that does not guarantee any memory synchronization.

Structs§