dscale 0.4.1

A fast & deterministic simulation framework for benchmarking and testing distributed systems
Documentation
use std::sync::atomic::{AtomicUsize, Ordering};

use log::debug;

use crate::Jiffies;

pub(crate) static GLOBAL_CLOCK: AtomicUsize = AtomicUsize::new(0);

pub(crate) fn fast_forward_clock(future: Jiffies) {
    let present = Jiffies(GLOBAL_CLOCK.swap(future.0, Ordering::Relaxed));
    debug_assert!(present <= future, "Future < Present");
    debug!("Global time now: {future}");
}

pub(crate) fn global_now() -> Jiffies {
    Jiffies(GLOBAL_CLOCK.load(Ordering::Relaxed))
}

pub(crate) fn reset() {
    GLOBAL_CLOCK.store(0, Ordering::Relaxed);
}