Skip to content

Commit

Permalink
rt: pop at least one task from inject queue
Browse files Browse the repository at this point in the history
When attempting to pull a batch of tasks from the injection queue,
ensure we set the cap to at least one.
  • Loading branch information
carllerche committed Aug 3, 2023
1 parent 38d1bcd commit bf3dce7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tokio/src/runtime/scheduler/multi_thread/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,10 @@ impl Core {
cap,
);

// Take at least one task since the first task is returned directly
// and nto pushed onto the local queue.
let n = usize::max(1, n);

let mut synced = worker.handle.shared.synced.lock();
// safety: passing in the correct `inject::Synced`.
let mut tasks = unsafe { worker.inject().pop_n(&mut synced.inject, n) };
Expand Down

0 comments on commit bf3dce7

Please sign in to comment.