Skip to main content

rvm_types/
scheduler.rs

1//! Scheduler types.
2
3/// Scheduler operating mode.
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum SchedulerMode {
6    /// Reflex mode: real-time, latency-sensitive.
7    Reflex,
8    /// Flow mode: throughput-optimized.
9    Flow,
10    /// Recovery mode: degraded, single-partition.
11    Recovery,
12}
13
14/// Priority level for scheduling.
15#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
16#[repr(transparent)]
17pub struct Priority(u8);
18
19impl Priority {
20    /// Highest priority.
21    pub const MAX: Self = Self(255);
22    /// Lowest priority.
23    pub const MIN: Self = Self(0);
24    /// Default priority.
25    pub const DEFAULT: Self = Self(128);
26
27    /// Create a new priority value.
28    #[must_use]
29    pub const fn new(val: u8) -> Self {
30        Self(val)
31    }
32
33    /// Return the raw priority value.
34    #[must_use]
35    pub const fn as_u8(self) -> u8 {
36        self.0
37    }
38}
39
40/// Configuration for a scheduler epoch.
41#[derive(Debug, Clone, Copy)]
42pub struct EpochConfig {
43    /// Epoch interval in nanoseconds.
44    pub interval_ns: u64,
45    /// Maximum partitions to switch per epoch.
46    pub max_switches: u16,
47}
48
49impl Default for EpochConfig {
50    fn default() -> Self {
51        Self {
52            interval_ns: 10_000_000, // 10 ms
53            max_switches: 64,
54        }
55    }
56}
57
58/// Summary of a scheduler epoch for witness logging.
59#[derive(Debug, Clone, Copy)]
60pub struct EpochSummary {
61    /// Epoch number.
62    pub epoch: u32,
63    /// Number of context switches in this epoch.
64    pub switch_count: u16,
65    /// Total partitions that were runnable.
66    pub runnable_count: u16,
67}