]> git.feebdaed.xyz Git - 0xmirror/tokio.git/commitdiff
time: address style issues (#7328)
authorQi <add_sp@outlook.com>
Mon, 12 May 2025 14:32:23 +0000 (22:32 +0800)
committerGitHub <noreply@github.com>
Mon, 12 May 2025 14:32:23 +0000 (23:32 +0900)
tokio/src/runtime/time/entry.rs
tokio/src/runtime/time/mod.rs
tokio/src/runtime/time/wheel/mod.rs

index 7991ee0dc0a898ec6fd86d33dfbfe9b02c27afa4..acf8f2f39ef9768c6b19162a3a9e35aba58d1686 100644 (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) => {
index 8cd51c5cb4ab607f0826c3818b77e1c8c25028f6..024fe77e9e742bcbe7832c83e67699e0fde905f0 100644 (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());
 
index 7040fc146b1b2c0f85093ccdc6efe203b3d31a0d..c0459ee737ce296db3a6caf538db5c4757cd05f2 100644 (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!(