runtime: clean up magic number in registration set (#7112)

This commit is contained in:
M.Amin Rayej 2025-01-21 17:10:32 +03:30 committed by GitHub
parent a82bdeebe9
commit 21a13f9eea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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<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();