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