Auto merge of #119863 - tmiasko:will-wake, r=m-ou-se
Waker::will_wake: Compare vtable address instead of its content Optimize will_wake implementation by comparing vtable address instead of its content. The existing best practice to avoid false negatives from will_wake is to define a waker vtable as a static item. That approach continues to works with the new implementation. While this potentially changes the observable behaviour, the function is documented to work on a best-effort basis. The PartialEq impl for RawWaker remains as it was.
This commit is contained in:
commit
62fb0db9a5
@ -441,7 +441,9 @@ pub fn wake_by_ref(&self) {
|
||||
#[must_use]
|
||||
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||
pub fn will_wake(&self, other: &Waker) -> bool {
|
||||
self.waker == other.waker
|
||||
let RawWaker { data: a_data, vtable: a_vtable } = self.waker;
|
||||
let RawWaker { data: b_data, vtable: b_vtable } = other.waker;
|
||||
a_data == b_data && ptr::eq(a_vtable, b_vtable)
|
||||
}
|
||||
|
||||
/// Creates a new `Waker` from [`RawWaker`].
|
||||
|
Loading…
Reference in New Issue
Block a user