Rollup merge of #93966 - rkuhn:patch-1, r=tmandry

document expectations for Waker::wake

fixes #93961

Opened PR for a discussion on the precise wording.
This commit is contained in:
Yuki Okushi 2022-05-25 07:08:41 +09:00 committed by GitHub
commit 33f45b167e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -218,6 +218,19 @@ unsafe impl Sync for Waker {}
impl Waker {
/// Wake up the task associated with this `Waker`.
///
/// As long as the runtime keeps running and the task is not finished, it is
/// guaranteed that each invocation of `wake` (or `wake_by_ref`) will be followed
/// by at least one `poll` of the task to which this `Waker` belongs. This makes
/// it possible to temporarily yield to other tasks while running potentially
/// unbounded processing loops.
///
/// Note that the above implies that multiple wake-ups may be coalesced into a
/// single `poll` invocation by the runtime.
///
/// Also note that yielding to competing tasks is not guaranteed: it is the
/// executors choice which task to run and the executor may choose to run the
/// current task again.
#[inline]
#[stable(feature = "futures_api", since = "1.36.0")]
pub fn wake(self) {