switchyard icon indicating copy to clipboard operation
switchyard copied to clipboard

Possible Problems When Waking with a Stale Waker

Open cwfitzgerald opened this issue 5 years ago • 1 comments

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?

cwfitzgerald avatar Oct 04 '20 04:10 cwfitzgerald

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.

Ralith avatar Aug 10 '24 21:08 Ralith