diff options
Diffstat (limited to 'src/task/__internal/atomic_waker.rs')
-rw-r--r-- | src/task/__internal/atomic_waker.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/task/__internal/atomic_waker.rs b/src/task/__internal/atomic_waker.rs index 0677e83..2fc594b 100644 --- a/src/task/__internal/atomic_waker.rs +++ b/src/task/__internal/atomic_waker.rs @@ -271,7 +271,12 @@ impl AtomicWaker { WAITING => { unsafe { // Locked acquired, update the waker cell - *self.waker.get() = Some(waker.clone()); + + // Avoid cloning the waker if the old waker will awaken the same task. + match &*self.waker.get() { + Some(old_waker) if old_waker.will_wake(waker) => (), + _ => *self.waker.get() = Some(waker.clone()), + } // Release the lock. If the state transitioned to include // the `WAKING` bit, this means that at least one wake has |