Skip to content

Commit

Permalink
Rollup merge of rust-lang#128882 - RalfJung:local-waker-will-wake, r=…
Browse files Browse the repository at this point in the history
…cuviper

make LocalWaker::will_wake consistent with Waker::will_wake

This mirrors rust-lang#119863 for `LocalWaker`. Looks like that got missed in the initial `LocalWaker` PR (rust-lang#118960).
  • Loading branch information
matthiaskrgr authored Aug 11, 2024
2 parents 16c9055 + ae09340 commit 72ddd9a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion library/core/src/task/wake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,8 @@ impl Waker {
#[must_use]
#[stable(feature = "futures_api", since = "1.36.0")]
pub fn will_wake(&self, other: &Waker) -> bool {
// We optimize this by comparing vtable addresses instead of vtable contents.
// This is permitted since the function is documented as best-effort.
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)
Expand Down Expand Up @@ -761,7 +763,11 @@ impl LocalWaker {
#[must_use]
#[unstable(feature = "local_waker", issue = "118959")]
pub fn will_wake(&self, other: &LocalWaker) -> bool {
self.waker == other.waker
// We optimize this by comparing vtable addresses instead of vtable contents.
// This is permitted since the function is documented as best-effort.
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 `LocalWaker` from [`RawWaker`].
Expand Down

0 comments on commit 72ddd9a

Please sign in to comment.