mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-24 00:00:11 +02:00
## Motivation PR #4055 added a new `WakeList` type, to manage a potentially uninitialized array when waking batches of wakers. This has the advantage of not initializing a bunch of empty `Option`s when only a small number of tasks are being woken, potentially improving performance in these cases. Currently, `WakeList` is used only in the IO driver. However, `tokio::sync` contains some code that's almost identical to the code in the IO driver that was replaced with `WakeList`, so we can apply the same optimizations there. ## Solution This branch changes `tokio::sync::Notify` and `tokio::sync::batch_semaphore::Semaphore` to use `WakeList` when waking batches of wakers. This was a pretty straightforward drop-in replacement. Signed-off-by: Eliza Weisman <[email protected]>
76 lines
1.6 KiB
Rust
76 lines
1.6 KiB
Rust
cfg_io_driver! {
|
|
pub(crate) mod bit;
|
|
pub(crate) mod slab;
|
|
}
|
|
|
|
#[cfg(any(
|
|
// io driver uses `WakeList` directly
|
|
feature = "net",
|
|
feature = "process",
|
|
// `sync` enables `Notify` and `batch_semaphore`, which require `WakeList`.
|
|
feature = "sync",
|
|
// `fs` uses `batch_semaphore`, which requires `WakeList`.
|
|
feature = "fs",
|
|
// rt and signal use `Notify`, which requires `WakeList`.
|
|
feature = "rt",
|
|
feature = "signal",
|
|
))]
|
|
mod wake_list;
|
|
#[cfg(any(
|
|
feature = "net",
|
|
feature = "process",
|
|
feature = "sync",
|
|
feature = "fs",
|
|
feature = "rt",
|
|
feature = "signal",
|
|
))]
|
|
pub(crate) use wake_list::WakeList;
|
|
|
|
#[cfg(any(
|
|
feature = "fs",
|
|
feature = "net",
|
|
feature = "process",
|
|
feature = "rt",
|
|
feature = "sync",
|
|
feature = "signal",
|
|
feature = "time",
|
|
))]
|
|
pub(crate) mod linked_list;
|
|
|
|
#[cfg(any(feature = "rt-multi-thread", feature = "macros"))]
|
|
mod rand;
|
|
|
|
cfg_rt! {
|
|
mod wake;
|
|
pub(crate) use wake::WakerRef;
|
|
pub(crate) use wake::{waker_ref, Wake};
|
|
|
|
mod sync_wrapper;
|
|
pub(crate) use sync_wrapper::SyncWrapper;
|
|
|
|
mod vec_deque_cell;
|
|
pub(crate) use vec_deque_cell::VecDequeCell;
|
|
}
|
|
|
|
cfg_rt_multi_thread! {
|
|
pub(crate) use self::rand::FastRand;
|
|
|
|
mod try_lock;
|
|
pub(crate) use try_lock::TryLock;
|
|
}
|
|
|
|
pub(crate) mod trace;
|
|
|
|
#[cfg(any(feature = "macros"))]
|
|
#[cfg_attr(not(feature = "macros"), allow(unreachable_pub))]
|
|
pub use self::rand::thread_rng_n;
|
|
|
|
#[cfg(any(
|
|
feature = "rt",
|
|
feature = "time",
|
|
feature = "net",
|
|
feature = "process",
|
|
all(unix, feature = "signal")
|
|
))]
|
|
pub(crate) mod error;
|