From 21a13f9eea1723f6ca1b5e106776d0b1d5df80ea Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Tue, 21 Jan 2025 17:10:32 +0330 Subject: [PATCH] runtime: clean up magic number in registration set (#7112) --- tokio/src/runtime/io/registration_set.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tokio/src/runtime/io/registration_set.rs b/tokio/src/runtime/io/registration_set.rs index 9b23732d96a..21f6c873fb1 100644 --- a/tokio/src/runtime/io/registration_set.rs +++ b/tokio/src/runtime/io/registration_set.rs @@ -7,6 +7,9 @@ use std::ptr::NonNull; use std::sync::atomic::Ordering::{Acquire, Release}; use std::sync::Arc; +// Kind of arbitrary, but buffering 16 `ScheduledIo`s doesn't seem like much +const NOTIFY_AFTER: usize = 16; + pub(super) struct RegistrationSet { num_pending_release: AtomicUsize, } @@ -35,7 +38,7 @@ impl RegistrationSet { let synced = Synced { is_shutdown: false, registrations: LinkedList::new(), - pending_release: Vec::with_capacity(16), + pending_release: Vec::with_capacity(NOTIFY_AFTER), }; (set, synced) @@ -69,9 +72,6 @@ impl RegistrationSet { // Returns `true` if the caller should unblock the I/O driver to purge // registrations pending release. pub(super) fn deregister(&self, synced: &mut Synced, registration: &Arc) -> bool { - // Kind of arbitrary, but buffering 16 `ScheduledIo`s doesn't seem like much - const NOTIFY_AFTER: usize = 16; - synced.pending_release.push(registration.clone()); let len = synced.pending_release.len();