time: address style issues (#7328)

This commit is contained in:
Qi
2025-05-12 23:32:23 +09:00
committed by GitHub
parent 0715e6defc
commit 4cbcb687f4
3 changed files with 8 additions and 7 deletions
+3 -3
View File
@@ -69,7 +69,7 @@ use std::{marker::PhantomPinned, pin::Pin, ptr::NonNull};
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.
@@ -273,7 +273,7 @@ impl StateCell {
/// 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
}
}
@@ -612,7 +612,7 @@ impl TimerHandle {
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) => {
+3 -3
View File
@@ -92,10 +92,10 @@ pub(crate) struct Driver {
/// 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
@@ -171,7 +171,7 @@ impl Driver {
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());
+2 -1
View File
@@ -7,6 +7,7 @@ use self::level::Level;
use std::{array, ptr::NonNull};
use super::entry::STATE_DEREGISTERED;
use super::EntryList;
/// Timing wheel implementation.
@@ -117,7 +118,7 @@ impl Wheel {
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!(