-
Notifications
You must be signed in to change notification settings - Fork 13.3k
LocalWaker and Waker cleanups #54732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Ping from triage @aturon / @rust-lang/libs: This PR requires your review. |
/// `Waker` is nearly identical to `LocalWaker`, but is threadsafe | ||
/// (implements `Send` and `Sync`). | ||
#[inline] | ||
pub fn as_waker(&self) -> &Waker { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this actually safe? With scoped threads it seems like you could use this to pass a LocalWaker
to another thread as a &Waker
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, you can! And that's totally safe, because you can only call .wake()
on the inner UnsafeWake
in a Wake
-- you can't call .wake_local()
.
@bors r+ |
📌 Commit 00e0565 has been approved by |
LocalWaker and Waker cleanups r? @aturon
☀️ Test successful - status-appveyor, status-travis |
@cramertj Bikeshedding... 🚲🚲🚲 I find names Compare: |
@stjepang There was a lot of debate back in the day about this, which ended in rust-lang/futures-rs#689 and rust-lang/futures-rs#1236, in an effort to prevent people from thinking of two different |
@cramertj Ah I see the problem, thanks for the explanation! Still, judging by the name, I had no idea what |
r? @aturon