mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Support promises in workers.
This commit is contained in:
parent
ef501603bf
commit
57b3ccd38c
4 changed files with 181 additions and 61 deletions
|
@ -25,7 +25,7 @@ use js::jsapi::HandleValue;
|
|||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::{CoreResourceThread, IpcSend, ResourceThreads};
|
||||
use profile_traits::{mem, time};
|
||||
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort};
|
||||
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, EnqueuedPromiseCallback};
|
||||
use script_thread::{MainThreadScriptChan, RunnableWrapper, ScriptThread};
|
||||
use script_traits::{MsDuration, ScriptMsg as ConstellationMsg, TimerEventRequest};
|
||||
use task_source::dom_manipulation::DOMManipulationTaskSource;
|
||||
|
@ -290,6 +290,23 @@ impl<'a> GlobalRef<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Enqueue a promise callback for subsequent execution.
|
||||
pub fn enqueue_promise_job(&self, job: EnqueuedPromiseCallback) {
|
||||
match *self {
|
||||
GlobalRef::Window(_) => ScriptThread::enqueue_promise_job(job, *self),
|
||||
GlobalRef::Worker(ref worker) => worker.enqueue_promise_job(job),
|
||||
}
|
||||
}
|
||||
|
||||
/// Start the process of executing the pending promise callbacks. They will be invoked
|
||||
/// in FIFO order, synchronously, at some point in the future.
|
||||
pub fn flush_promise_jobs(&self) {
|
||||
match *self {
|
||||
GlobalRef::Window(_) => ScriptThread::flush_promise_jobs(*self),
|
||||
GlobalRef::Worker(ref worker) => worker.flush_promise_jobs(),
|
||||
}
|
||||
}
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/#report-the-error
|
||||
pub fn report_an_error(&self, error_info: ErrorInfo, value: HandleValue) {
|
||||
match *self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue