Skip to content

timers should be represented by ports #10014

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

Closed
metajack opened this issue Oct 22, 2013 · 0 comments · Fixed by #10083
Closed

timers should be represented by ports #10014

metajack opened this issue Oct 22, 2013 · 0 comments · Fixed by #10083
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows

Comments

@metajack
Copy link
Contributor

The timer code currently has a fundamental flaw, which is that it blocks the task in sleep() and can't be awoken or killed. Instead of exposing sleep, timers should be represented by ports which you recv() on and get a message when the timer fires. Then things making timers could cancel them. Using select on timer and another port could be used to implement timeout messages, etc.

We found this in servo, because calling setTimeout in JavaScript spawns a task that calls sleep and then sends a message. You can't cancel such a timer and exiting before the timer fires is impossible since you can't force kill the task.

cc: @jdm

bors added a commit that referenced this issue Oct 28, 2013
In addition to being able to sleep the current task, timers should be able to
create ports which get notified after a period of time.

Closes #10014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant