Skip to content

Commit 7c54fdc

Browse files
authored
rt: pop at least one task from inject queue (#5908)
When attempting to pull a batch of tasks from the injection queue, ensure we set the cap to at least one.
1 parent 38d1bcd commit 7c54fdc

File tree

1 file changed

+4
-0
lines changed
  • tokio/src/runtime/scheduler/multi_thread

1 file changed

+4
-0
lines changed

tokio/src/runtime/scheduler/multi_thread/worker.rs

+4
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,10 @@ impl Core {
787787
cap,
788788
);
789789

790+
// Take at least one task since the first task is returned directly
791+
// and nto pushed onto the local queue.
792+
let n = usize::max(1, n);
793+
790794
let mut synced = worker.handle.shared.synced.lock();
791795
// safety: passing in the correct `inject::Synced`.
792796
let mut tasks = unsafe { worker.inject().pop_n(&mut synced.inject, n) };

0 commit comments

Comments
 (0)