mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Allow wrapping worker runnables in cancellable runnables.
This commit is contained in:
parent
2cab846140
commit
0e4865ea1a
2 changed files with 17 additions and 1 deletions
|
@ -23,7 +23,7 @@ use net_traits::filemanager_thread::FileManagerThreadMsg;
|
|||
use net_traits::{ResourceThreads, CoreResourceThread, RequestSource, IpcSend};
|
||||
use profile_traits::{mem, time};
|
||||
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort};
|
||||
use script_thread::{MainThreadScriptChan, ScriptThread};
|
||||
use script_thread::{MainThreadScriptChan, ScriptThread, RunnableWrapper};
|
||||
use script_traits::{MsDuration, ScriptMsg as ConstellationMsg, TimerEventRequest};
|
||||
use task_source::dom_manipulation::DOMManipulationTaskSource;
|
||||
use timers::{OneshotTimerCallback, OneshotTimerHandle};
|
||||
|
@ -297,6 +297,15 @@ impl<'a> GlobalRef<'a> {
|
|||
GlobalRef::Worker(ref worker) => worker.panic_chan(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a wrapper for runnables to ensure they are cancelled if the global
|
||||
/// is being destroyed.
|
||||
pub fn get_runnable_wrapper(&self) -> RunnableWrapper {
|
||||
match *self {
|
||||
GlobalRef::Window(ref window) => window.get_runnable_wrapper(),
|
||||
GlobalRef::Worker(ref worker) => worker.get_runnable_wrapper(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GlobalRoot {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue