mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-10-01 12:20:39 +00:00
metrics: fix worker_steal_count test hanging (#6327)
This commit is contained in:
parent
fbdf539ac2
commit
47a5fe3a12
@ -181,7 +181,7 @@ fn worker_steal_count() {
|
|||||||
// We use a blocking channel to backup one worker thread.
|
// We use a blocking channel to backup one worker thread.
|
||||||
use std::sync::mpsc::channel;
|
use std::sync::mpsc::channel;
|
||||||
|
|
||||||
let rt = threaded();
|
let rt = threaded_no_lifo();
|
||||||
let metrics = rt.metrics();
|
let metrics = rt.metrics();
|
||||||
|
|
||||||
rt.block_on(async {
|
rt.block_on(async {
|
||||||
@ -190,14 +190,12 @@ fn worker_steal_count() {
|
|||||||
// Move to the runtime.
|
// Move to the runtime.
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
// Spawn the task that sends to the channel
|
// Spawn the task that sends to the channel
|
||||||
|
//
|
||||||
|
// Since the lifo slot is disabled, this task is stealable.
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
tx.send(()).unwrap();
|
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.
|
// Blocking receive on the channel.
|
||||||
rx.recv().unwrap();
|
rx.recv().unwrap();
|
||||||
})
|
})
|
||||||
@ -729,6 +727,15 @@ fn threaded() -> Runtime {
|
|||||||
.unwrap()
|
.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 {
|
fn us(n: u64) -> Duration {
|
||||||
Duration::from_micros(n)
|
Duration::from_micros(n)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user