devela/work/process/thread/sleep/
spin.rs

1// devela::work::process::thread::sleep::spin
2//
3//! Spin sleeping functionality.
4//
5
6#![allow(unused)]
7
8use crate::{Duration};
9
10///
11#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
12pub struct SleepSpin {
13    backoff: SpinStrategy,
14}
15
16impl SleepSpin {
17    /// Creates a new spin sleeper with the default backoff strategy.
18    pub const fn new() -> Self {
19        todo![]
20    }
21
22    /// Spins until `condition()` returns true or the duration is elapsed.
23    pub fn sleep_until<F: Fn() -> bool>(&mut self, timeout: Duration, condition: F) -> bool {
24        todo!{}
25    }
26
27    /// Spins for `duration`, adjusting with backoff.
28    pub fn sleep_for(&mut self, duration: Duration) {
29        todo![]
30    }
31}
32
33///
34#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
35pub enum SpinStrategy {
36    /// Pure busy-wait (for ultra-low latency).
37    #[default]
38    Immediate,
39
40    /// Calls core::hint::spin_loop() to allow SMT cores to optimize.
41    Yielding,
42
43    /// Increases wait times to avoid contention.
44    ExpBackoff,
45}