We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Waker::will_wake()
1 parent 066f1d0 commit cc0e342Copy full SHA for cc0e342
futures-core/src/task/__internal/atomic_waker.rs
@@ -271,7 +271,12 @@ impl AtomicWaker {
271
WAITING => {
272
unsafe {
273
// Locked acquired, update the waker cell
274
- *self.waker.get() = Some(waker.clone());
+
275
+ // Avoid cloning the waker if the old waker will awaken the same task.
276
+ match &*self.waker.get() {
277
+ Some(old_waker) if old_waker.will_wake(waker) => (),
278
+ _ => *self.waker.get() = Some(waker.clone()),
279
+ }
280
281
// Release the lock. If the state transitioned to include
282
// the `WAKING` bit, this means that at least one wake has
0 commit comments