Skip to content

clarify the semantics of core::task::Waker::wake() #93961

Closed
@rkuhn

Description

@rkuhn

Based on reading e.g. the Tokio sources and knowledge passed down from async monks to novices, I assume that calling cx.waker().wake_by_ref() from the task that is currently being polled will ensure that the task is polled again soon, even if no external reason arises. However, this behaviour is not documented, at least not unambiguously — the documentation for core::future::Future only states that the waker provided by the context can be used to wake up the task, which may technically require the task to be “sleeping” for this to have an effect.

If there is consensus that wake_by_ref will always and unconditionally ensure one further call to poll, then we should document this expectation as part of the Future contract. Who agrees? Anyone against? Am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions