-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: support non-unique handles for timers #71
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand the problem correctly, all timers in Fastly's implementation have PollableHandle == -2
because of how timeouts are translated, right?
If so, that makes sense to me, yeah.
The tricky bit, and why I didn't immediately implement things this way, is that the TimerTask
s in the map need to be properly rooted—see the comment in-line.
fce8334
to
887f782
Compare
Yes exactly. I've implemented a very naive singleton and trace model here as a start. Further feedback very much welcome. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I left a bunch of suggestions which should be applied (and then a little bit of other tweaks as follow-ups to those, because I didn't add suggestions for all the places where s/timer_ids_/timers_/g
needs to happen), but with those in, this'll be ready to go!
Co-authored-by: Till Schneidereit <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh huh, seems like that doesn't work with raw pointers, sorry!
The suggested edits do make it work, because tracing is implemented for js::UniquePtr
.
Co-authored-by: Till Schneidereit <[email protected]>
This was necessary to get one of the WPT cases to pass for Fastly's implementation.
Our implementation of checking task deadlines for timer tasks uses a redundant singular invalid handle (
-2
) to indicate a timer handle for a non-existent subscription. If we gave every timer a unique handle we would be using up the real handle ID space.But the
cancel_task
currently assumes handle uniqueness when finding the handle.This supports non-unique handles for tasks by taking the task itself to
cancel_task
instead of its handle to look it up from, storing timers as a map from timer ids to task pointers.I can confirm this is working correctly in the WPT test case for Fastly.