Closed
Description
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