Clarification needed on what happens when `Future::poll` wakes an old waker
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Location
https://doc.rust-lang.org/std/future/trait.Future.html#tymethod.poll
Summary
The documentation for Future::poll reads:
Note that on multiple calls to
poll, only theWakerfrom theContextpassed to the most recent call should be scheduled to receive a wakeup.
The implications of violating this aren’t specified. One might conclude that it is a bug to wake both the old and new wakers, as it says only the new one should be used. On the other hand, it says “should”, not “must”.
Note that there is no way to avoid waking both wakers in certain cases. See for instance the answer to In async Rust, how can a Future make sure it only calls the most recent Waker?, which reads:
This may cause the old waker to be woken unnecessarily, but that's fine.
I believe the intent of this requirement for poll is that there is no guarantee waking old wakers has any effect, but it is not a bug to wake them in addition to waking the most recent one. Is that correct? If so we may want to clarify this, preferably replacing the word “should” with something more concrete.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Future::poll documentation at the linked std::future::Future entry point and review the wording about the most recent Waker. Determine whether waking an older waker is permitted and what guarantee the documentation should state. Done means the documentation clearly resolves the ambiguity without asserting behavior unsupported by the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100