diff --git a/tokio/tests/rt_metrics.rs b/tokio/tests/rt_metrics.rs index 38bc18f7b6f..ec4856cb5c2 100644 --- a/tokio/tests/rt_metrics.rs +++ b/tokio/tests/rt_metrics.rs @@ -181,7 +181,7 @@ fn worker_steal_count() { // We use a blocking channel to backup one worker thread. use std::sync::mpsc::channel; - let rt = threaded(); + let rt = threaded_no_lifo(); let metrics = rt.metrics(); rt.block_on(async { @@ -190,14 +190,12 @@ fn worker_steal_count() { // Move to the runtime. tokio::spawn(async move { // Spawn the task that sends to the channel + // + // Since the lifo slot is disabled, this task is stealable. tokio::spawn(async move { tx.send(()).unwrap(); }); - // Spawn a task that bumps the previous task out of the "next - // scheduled" slot. - tokio::spawn(async {}); - // Blocking receive on the channel. rx.recv().unwrap(); }) @@ -729,6 +727,15 @@ fn threaded() -> Runtime { .unwrap() } +fn threaded_no_lifo() -> Runtime { + tokio::runtime::Builder::new_multi_thread() + .worker_threads(2) + .disable_lifo_slot() + .enable_all() + .build() + .unwrap() +} + fn us(n: u64) -> Duration { Duration::from_micros(n) }