Generalize promise job queue into solitary microtask queue.

This commit is contained in:
Josh Matthews 2017-01-12 12:39:05 -05:00
parent bac2f68b54
commit 32d4f84a30
8 changed files with 137 additions and 144 deletions

View file

@ -210,10 +210,15 @@ impl ServiceWorkerGlobalScope {
global.dispatch_activate();
let reporter_name = format!("service-worker-reporter-{}", random::<u64>());
scope.upcast::<GlobalScope>().mem_profiler_chan().run_with_memory_reporting(|| {
// https://html.spec.whatwg.org/multipage/#event-loop-processing-model
// Step 1
while let Ok(event) = global.receive_event() {
// Step 3
if !global.handle_event(event) {
break;
}
// Step 6
global.upcast::<WorkerGlobalScope>().perform_a_microtask_checkpoint();
}
}, reporter_name, scope.script_chan(), CommonScriptMsg::CollectReports);
}).expect("Thread spawning failed");