diff --git a/tokio/src/runtime/scheduler/multi_thread/idle.rs b/tokio/src/runtime/scheduler/multi_thread/idle.rs index 1046a0b6e..b91b741a1 100644 --- a/tokio/src/runtime/scheduler/multi_thread/idle.rs +++ b/tokio/src/runtime/scheduler/multi_thread/idle.rs @@ -15,11 +15,6 @@ pub(super) struct Idle { /// Used to catch false-negatives when notifying workers. needs_searching: AtomicBool, - // /// Tracks both the number of searching workers and the number of unparked - // /// workers. - // /// - // /// Used as a fast-path to avoid acquiring the lock when needed. - // state: AtomicUsize, /// Sleeping workers sleepers: Mutex>, diff --git a/tokio/src/runtime/scheduler/multi_thread/worker.rs b/tokio/src/runtime/scheduler/multi_thread/worker.rs index 5b1702fc9..b452f386f 100644 --- a/tokio/src/runtime/scheduler/multi_thread/worker.rs +++ b/tokio/src/runtime/scheduler/multi_thread/worker.rs @@ -703,6 +703,10 @@ impl Core { } fn transition_to_searching(&mut self, worker: &Worker) -> bool { + if did_defer_tasks() { + return false; + } + if !self.is_searching { self.is_searching = worker .handle