Skip to content

Commit 9a95573

Browse files
committed
Add cautionary paragraph about noop wakers.
Based on a suggestion from @kpreid, with some further editing.
1 parent c404406 commit 9a95573

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

library/core/src/task/wake.rs

+8
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,10 @@ impl Waker {
539539
/// some futures, but are not expecting those futures to wake the waker or
540540
/// do not need to do anything specific if it happens.
541541
///
542+
/// More generally, using `Waker::noop()` to poll a future
543+
/// means discarding the notification of when the future should be polled again.
544+
/// So it should only be used when such a notification will not be needed to make progress.
545+
///
542546
/// If an owned `Waker` is needed, `clone()` this one.
543547
///
544548
/// # Examples
@@ -796,6 +800,10 @@ impl LocalWaker {
796800
/// some futures, but are not expecting those futures to wake the waker or
797801
/// do not need to do anything specific if it happens.
798802
///
803+
/// More generally, using `LocalWaker::noop()` to poll a future
804+
/// means discarding the notification of when the future should be polled again,
805+
/// So it should only be used when such a notification will not be needed to make progress.
806+
///
799807
/// If an owned `LocalWaker` is needed, `clone()` this one.
800808
///
801809
/// # Examples

0 commit comments

Comments
 (0)