mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-10-01 12:20:39 +00:00
metrics: removed race condition from global_queue_depth_multi_thread test (#6936)
This commit is contained in:
parent
946401c345
commit
070a825999
@ -66,10 +66,10 @@ fn global_queue_depth_current_thread() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn global_queue_depth_multi_thread() {
|
fn global_queue_depth_multi_thread() {
|
||||||
|
for _ in 0..10 {
|
||||||
let rt = threaded();
|
let rt = threaded();
|
||||||
let metrics = rt.metrics();
|
let metrics = rt.metrics();
|
||||||
|
|
||||||
for _ in 0..10 {
|
|
||||||
if let Ok(_blocking_tasks) = try_block_threaded(&rt) {
|
if let Ok(_blocking_tasks) = try_block_threaded(&rt) {
|
||||||
for i in 0..10 {
|
for i in 0..10 {
|
||||||
assert_eq!(i, metrics.global_queue_depth());
|
assert_eq!(i, metrics.global_queue_depth());
|
||||||
@ -93,7 +93,7 @@ fn try_block_threaded(rt: &Runtime) -> Result<Vec<mpsc::Sender<()>>, mpsc::RecvT
|
|||||||
|
|
||||||
// Spawn a task per runtime worker to block it.
|
// Spawn a task per runtime worker to block it.
|
||||||
rt.spawn(async move {
|
rt.spawn(async move {
|
||||||
tx.send(()).unwrap();
|
tx.send(()).ok();
|
||||||
barrier.recv().ok();
|
barrier.recv().ok();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user