Skip to content

Commit

Permalink
Removed race condition from global_queue_depth_multi_thread test
Browse files Browse the repository at this point in the history
  • Loading branch information
jofas committed Oct 25, 2024
1 parent ebe2416 commit 8235535
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tokio/tests/rt_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ fn global_queue_depth_current_thread() {

#[test]
fn global_queue_depth_multi_thread() {
let rt = threaded();
let metrics = rt.metrics();

for _ in 0..10 {
let rt = threaded();
let metrics = rt.metrics();

if let Ok(_blocking_tasks) = try_block_threaded(&rt) {
for i in 0..10 {
assert_eq!(i, metrics.global_queue_depth());
Expand All @@ -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.
rt.spawn(async move {
tx.send(()).unwrap();
tx.send(()).ok();
barrier.recv().ok();
});

Expand Down

0 comments on commit 8235535

Please sign in to comment.