view src/env_common.rs @ 634:0b2bc7b8634b

chore: Add gitignore
author Darius <darius.clark@proton.me>
date Wed, 03 Apr 2024 00:38:29 -0400
parents 0c3b736b2781
children
line wrap: on
line source

use std::thread;
use std::time;

pub fn micros() -> u64 {
    loop {
        let now = time::SystemTime::now().duration_since(time::UNIX_EPOCH);

        match now {
            Err(_) => continue,
            Ok(dur) => return dur.as_secs() * 1000000 + dur.subsec_micros() as u64,
        }
    }
}

pub fn sleep_for(micros: u32) {
    thread::sleep(time::Duration::new(0, micros * 1000));
}