use crate::Deadline;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct TimerOwnerId(u64);
impl TimerOwnerId {
pub const fn new(value: u64) -> Self {
Self(value)
}
pub const fn get(self) -> u64 {
self.0
}
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct TimerId(u64);
impl TimerId {
pub const ZERO: Self = Self(0);
pub const fn new(value: u64) -> Self {
Self(value)
}
pub const fn get(self) -> u64 {
self.0
}
pub(super) const fn checked_next(self) -> Option<Self> {
match self.0.checked_add(1) {
Some(value) => Some(Self(value)),
None => None,
}
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct TimerToken {
owner: TimerOwnerId,
id: TimerId,
deadline: Deadline,
}
impl TimerToken {
pub(super) const fn new(owner: TimerOwnerId, id: TimerId, deadline: Deadline) -> Self {
Self {
owner,
id,
deadline,
}
}
pub const fn owner(self) -> TimerOwnerId {
self.owner
}
pub const fn id(self) -> TimerId {
self.id
}
pub const fn deadline(self) -> Deadline {
self.deadline
}
}