Skip to content

Commit

Permalink
Add cautionary paragraph about noop wakers.
Browse files Browse the repository at this point in the history
Based on a suggestion from @kpreid, with some further editing.
  • Loading branch information
ijackson committed Aug 5, 2024
1 parent 275d31d commit bd8d151
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions library/core/src/task/wake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,10 @@ impl Waker {
/// some futures, but are not expecting those futures to wake the waker or
/// do not need to do anything specific if it happens.
///
/// More generally, using `Waker::noop()` to poll a future
/// means discarding the notification of when the future should be polled again.
/// So it should only be used when such a notification will not be needed to make progress.
///
/// If an owned `Waker` is needed, `clone()` this one.
///
/// # Examples
Expand Down Expand Up @@ -796,6 +800,10 @@ impl LocalWaker {
/// some futures, but are not expecting those futures to wake the waker or
/// do not need to do anything specific if it happens.
///
/// More generally, using `LocalWaker::noop()` to poll a future
/// means discarding the notification of when the future should be polled again,
/// So it should only be used when such a notification will not be needed to make progress.
///
/// If an owned `LocalWaker` is needed, `clone()` this one.
///
/// # Examples
Expand Down

0 comments on commit bd8d151

Please sign in to comment.