use crate::{Deadline, RetainedBytes};
use super::{TimerId, TimerLimits, TimerOwnerId};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct TimerDrain {
fired: usize,
more_due: bool,
}
impl TimerDrain {
pub(super) const fn new(fired: usize, more_due: bool) -> Self {
Self { fired, more_due }
}
pub const fn fired(self) -> usize {
self.fired
}
pub const fn more_due(self) -> bool {
self.more_due
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct TimerQueueSnapshot {
owner: TimerOwnerId,
limits: TimerLimits,
pending_timers: usize,
retained_bytes: RetainedBytes,
next_deadline: Option<Deadline>,
next_id: Option<TimerId>,
}
impl TimerQueueSnapshot {
pub(super) const fn new(
owner: TimerOwnerId,
limits: TimerLimits,
pending_timers: usize,
retained_bytes: RetainedBytes,
next_deadline: Option<Deadline>,
next_id: Option<TimerId>,
) -> Self {
Self {
owner,
limits,
pending_timers,
retained_bytes,
next_deadline,
next_id,
}
}
pub const fn owner(self) -> TimerOwnerId {
self.owner
}
pub const fn limits(self) -> TimerLimits {
self.limits
}
pub const fn pending_timers(self) -> usize {
self.pending_timers
}
pub const fn retained_bytes(self) -> RetainedBytes {
self.retained_bytes
}
pub const fn next_deadline(self) -> Option<Deadline> {
self.next_deadline
}
pub const fn next_id(self) -> Option<TimerId> {
self.next_id
}
pub const fn identities_exhausted(self) -> bool {
self.next_id.is_none()
}
}