Version
1.49.0 and above (since the alternative timer was added)
Platform
N/A
Description
The alt timer does not retain the previous waker in Sleep::reset. When sharing Sleep and DelayQueue between tasks (e.g. Arc<Mutex<Pin<Box<Sleep>>>>), a task may lose its waker if another task calls reset. Waker retention was added in #2217 and #2290 (back in 0.2).
Rather than fixing the alternative timer, I would rather remove these spurious wakes and label cross-task sharing unsupported. This would be a minor compatibility break, as I doubt anyone actually uses this functionality (and whether we even knew about it). Alternatively, this should at least be internally documented, and perhaps publicly as well.
With this removed from Sleep, we would no longer need to store Option<Waker> in DelayQueue. That waker is only necessary to wake the task currently calling poll_expired after insert/remove operations (allowing it to reschedule itself).
Discovered in #8137, when I tried to normalize both implementations. This was not caught by our tests, as the alternative timer requires the multi-threaded runtime but our tests run on the current-threaded runtime.
Version
1.49.0 and above (since the alternative timer was added)
Platform
N/A
Description
The alt timer does not retain the previous waker in
Sleep::reset. When sharingSleepandDelayQueuebetween tasks (e.g.Arc<Mutex<Pin<Box<Sleep>>>>), a task may lose its waker if another task callsreset. Waker retention was added in #2217 and #2290 (back in 0.2).Rather than fixing the alternative timer, I would rather remove these spurious wakes and label cross-task sharing unsupported. This would be a minor compatibility break, as I doubt anyone actually uses this functionality (and whether we even knew about it). Alternatively, this should at least be internally documented, and perhaps publicly as well.
With this removed from
Sleep, we would no longer need to storeOption<Waker>inDelayQueue. That waker is only necessary to wake the task currently callingpoll_expiredafterinsert/removeoperations (allowing it to reschedule itself).Discovered in #8137, when I tried to normalize both implementations. This was not caught by our tests, as the alternative timer requires the multi-threaded runtime but our tests run on the current-threaded runtime.