type TimerResult = Result<(), crate::time::error::Error>;
-const STATE_DEREGISTERED: u64 = u64::MAX;
+pub(in crate::runtime::time) const STATE_DEREGISTERED: u64 = u64::MAX;
const STATE_PENDING_FIRE: u64 = STATE_DEREGISTERED - 1;
const STATE_MIN_VALUE: u64 = STATE_PENDING_FIRE;
/// The largest safe integer to use for ticks.
/// ordering, but is conservative - if it returns false, the timer is
/// definitely _not_ registered.
pub(super) fn might_be_registered(&self) -> bool {
- self.state.load(Ordering::Relaxed) != u64::MAX
+ self.state.load(Ordering::Relaxed) != STATE_DEREGISTERED
}
}
match self.inner.as_ref().state.mark_pending(not_after) {
Ok(()) => {
// mark this as being on the pending queue in cached_when
- self.inner.as_ref().set_cached_when(u64::MAX);
+ self.inner.as_ref().set_cached_when(STATE_DEREGISTERED);
Ok(())
}
Err(tick) => {
/// Timer state shared between `Driver`, `Handle`, and `Registration`.
struct Inner {
// The state is split like this so `Handle` can access `is_shutdown` without locking the mutex
- pub(super) state: Mutex<InnerState>,
+ state: Mutex<InnerState>,
/// True if the driver is being shutdown.
- pub(super) is_shutdown: AtomicBool,
+ is_shutdown: AtomicBool,
// When `true`, a call to `park_timeout` should immediately return and time
// should not advance. One reason for this to be `true` is if the task
fn park_internal(&mut self, rt_handle: &driver::Handle, limit: Option<Duration>) {
let handle = rt_handle.time();
- let mut lock = handle.inner.state.lock();
+ let mut lock = handle.inner.lock();
assert!(!handle.is_shutdown());
use std::{array, ptr::NonNull};
+use super::entry::STATE_DEREGISTERED;
use super::EntryList;
/// Timing wheel implementation.
pub(crate) unsafe fn remove(&mut self, item: NonNull<TimerShared>) {
unsafe {
let when = item.as_ref().cached_when();
- if when == u64::MAX {
+ if when == STATE_DEREGISTERED {
self.pending.remove(item);
} else {
debug_assert!(