externally-driven-async-rt 0.5.0

Async runtime that is meant to be embedded
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use core::{
    sync::atomic::{AtomicU64, Ordering::Relaxed},
    time::Duration,
};

use crate::time::{Instant, Timers};

pub(crate) fn fake_instant(millis: &AtomicU64) -> Instant {
    Instant::ZERO.saturating_add(Duration::from_millis(millis.load(Relaxed)))
}

pub(crate) fn wake_expired_timers<const TIMERS: usize>(timers: &Timers<TIMERS>) {
    let now = timers.now();
    while let Some(waker) = timers.take_expired(now) {
        waker.wake();
    }
}