Skip to content

Commit

Permalink
runtime: clean up magic number in registration set (#7112)
Browse files Browse the repository at this point in the history
  • Loading branch information
maminrayej authored Jan 21, 2025
1 parent a82bdee commit 21a13f9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tokio/src/runtime/io/registration_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<ScheduledIo>) -> 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();
Expand Down

0 comments on commit 21a13f9

Please sign in to comment.