Skip to content

Commit 855e269

Browse files
committed
Remove num_notify, it's not longer needed
1 parent 126cb78 commit 855e269

File tree

1 file changed

+0
-30
lines changed

1 file changed

+0
-30
lines changed

tokio/src/runtime/blocking/sharded_queue.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,6 @@ pub(super) struct ShardedQueue {
7979
condvar: Condvar,
8080
/// Mutex to pair with the condvar. Only held during wait, not during push/pop.
8181
condvar_mutex: Mutex<()>,
82-
/// Tracks pending wakeup notifications.
83-
///
84-
/// When a task is pushed, we increment this counter and signal the condvar.
85-
/// When a worker wakes up, it decrements this counter (if positive) to "claim"
86-
/// the notification. This helps workers distinguish between:
87-
/// - Waking up because a task was pushed (counter was positive)
88-
/// - Spurious wakeup from the condvar (counter was zero)
89-
///
90-
/// Multiple workers may race to decrement the counter, which is fine - the
91-
/// worker that successfully decrements will likely find the task, while
92-
/// others will re-check and either find other tasks or go back to sleep.
93-
num_notify: AtomicUsize,
9482
}
9583

9684
/// Calculate the effective number of shards to use based on thread count.
@@ -114,7 +102,6 @@ impl ShardedQueue {
114102
shutdown: AtomicBool::new(false),
115103
condvar: Condvar::new(),
116104
condvar_mutex: Mutex::new(()),
117-
num_notify: AtomicUsize::new(0),
118105
}
119106
}
120107

@@ -135,7 +122,6 @@ impl ShardedQueue {
135122

136123
/// Notify one waiting worker that a task is available.
137124
pub(super) fn notify_one(&self) {
138-
self.num_notify.fetch_add(1, Release);
139125
self.condvar.notify_one();
140126
}
141127

@@ -229,22 +215,6 @@ impl ShardedQueue {
229215
return WaitResult::Shutdown;
230216
}
231217

232-
// Try to claim a pending notification by decrementing the counter.
233-
// This is a compare-and-swap loop that only decrements if positive.
234-
loop {
235-
let current = self.num_notify.load(Acquire);
236-
if current == 0 {
237-
break;
238-
}
239-
match self
240-
.num_notify
241-
.compare_exchange_weak(current, current - 1, Release, Relaxed)
242-
{
243-
Ok(_) => break,
244-
Err(_) => continue,
245-
}
246-
}
247-
248218
// Try to get a task
249219
if let Some(task) = self.pop(preferred_shard) {
250220
return WaitResult::Task(task);

0 commit comments

Comments
 (0)