kernel_api/syscall/server.rs
1use crate::time::Instant;
2
3#[derive(Hash, Eq, PartialEq, Clone, Copy, Debug, Ord, PartialOrd)]
4pub struct ServerId(usize, u64);
5
6impl ServerId {
7 #[doc(hidden)]
8 pub const MAX: usize = u16::MAX as usize;
9
10 /// A sentinel `ServerId` value which is guaranteed to never be assigned to a server
11 pub const INVALID: ServerId = ServerId(usize::MAX, 0);
12
13 #[doc(hidden)]
14 pub fn new(val: u16) -> Self { Self(val.into(), Instant::now().get() as u64) } // assuming arch val is clock cycles, still takes >100 years to overflow generation number creating a new server every clock cycle at 5GHz
15}