Skip to content

Commit 33f45b1

Browse files
authored
Rollup merge of rust-lang#93966 - rkuhn:patch-1, r=tmandry
document expectations for Waker::wake fixes rust-lang#93961 Opened PR for a discussion on the precise wording.
2 parents 76761db + 3d808d5 commit 33f45b1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

library/core/src/task/wake.rs

+13
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,19 @@ unsafe impl Sync for Waker {}
218218

219219
impl Waker {
220220
/// Wake up the task associated with this `Waker`.
221+
///
222+
/// As long as the runtime keeps running and the task is not finished, it is
223+
/// guaranteed that each invocation of `wake` (or `wake_by_ref`) will be followed
224+
/// by at least one `poll` of the task to which this `Waker` belongs. This makes
225+
/// it possible to temporarily yield to other tasks while running potentially
226+
/// unbounded processing loops.
227+
///
228+
/// Note that the above implies that multiple wake-ups may be coalesced into a
229+
/// single `poll` invocation by the runtime.
230+
///
231+
/// Also note that yielding to competing tasks is not guaranteed: it is the
232+
/// executor’s choice which task to run and the executor may choose to run the
233+
/// current task again.
221234
#[inline]
222235
#[stable(feature = "futures_api", since = "1.36.0")]
223236
pub fn wake(self) {

0 commit comments

Comments
 (0)