switchyard
switchyard copied to clipboard
Possible Problems When Waking with a Stale Waker
consider these events:
- spawn
- poll; waker is saved elsewhere
- wake_by_ref with saved waker
- poll; waker is ignored
- wake_by_ref with saved waker
the second wake_by_ref will be dropped on the floor. Is this a problem? Can real futures do this? Is this supported by existing runtimes?
The fundamental rule of implementing a future is "never return Pending without saving the waker". If the second poll returns Pending, then the latest waker must have been saved. An out-of-date waker is necessarily one that the future is no longer interested in, since it didn't poll it since (potentially) acquiring a new waker.