diff options
author | Josh Matthews <josh@joshmatthews.net> | 2016-07-14 13:05:01 -0400 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2016-07-14 13:27:41 -0400 |
commit | 2aef518ce672b8037913fb1a33980475e02259f8 (patch) | |
tree | e0d1a1286ce653115c661867ad286ece6a138b43 /components/script/task_source/mod.rs | |
parent | 0e4865ea1ada7294d89581704f047b521f985c69 (diff) | |
download | servo-2aef518ce672b8037913fb1a33980475e02259f8.tar.gz servo-2aef518ce672b8037913fb1a33980475e02259f8.zip |
Make task queue API usable from non-main threads.
Diffstat (limited to 'components/script/task_source/mod.rs')
-rw-r--r-- | components/script/task_source/mod.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/components/script/task_source/mod.rs b/components/script/task_source/mod.rs index 48fc775d959..cb607c57acb 100644 --- a/components/script/task_source/mod.rs +++ b/components/script/task_source/mod.rs @@ -8,10 +8,17 @@ pub mod history_traversal; pub mod networking; pub mod user_interaction; -use dom::window::Window; -use script_thread::Runnable; +use dom::bindings::global::GlobalRef; +use script_thread::{Runnable, RunnableWrapper}; use std::result::Result; pub trait TaskSource { - fn queue<T: Runnable + Send + 'static>(&self, msg: Box<T>, window: &Window) -> Result<(), ()>; + fn queue_with_wrapper<T>(&self, + msg: Box<T>, + wrapper: &RunnableWrapper) + -> Result<(), ()> + where T: Runnable + Send + 'static; + fn queue<T: Runnable + Send + 'static>(&self, msg: Box<T>, global: GlobalRef) -> Result<(), ()> { + self.queue_with_wrapper(msg, &global.get_runnable_wrapper()) + } } |