Force all messages to worker tasks to send a TrustedWorkerAddress along with the ScriptMsg. This ensures that the main-thread Worker object is rooted for as long as there are events in flight or being processed.

This commit is contained in:
Josh Matthews 2014-12-02 16:54:43 -08:00
parent 2f059c15e7
commit 9a7cd31134
11 changed files with 234 additions and 121 deletions

View file

@ -100,7 +100,7 @@ impl TimerManager {
timeout: i32,
is_interval: IsInterval,
source: TimerSource,
script_chan: ScriptChan)
script_chan: Box<ScriptChan+Send>)
-> i32 {
let timeout = cmp::max(0, timeout) as u64;
let handle = self.next_timer_handle.get();
@ -136,8 +136,7 @@ impl TimerManager {
let id = select.wait();
if id == timeout_handle.id() {
timeout_port.recv();
let ScriptChan(ref chan) = script_chan;
chan.send(ScriptMsg::FireTimer(source, TimerId(handle)));
script_chan.send(ScriptMsg::FireTimer(source, TimerId(handle)));
if is_interval == IsInterval::NonInterval {
break;
}