mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Introduce GlobalScope::get_runnable_wrapper
This commit is contained in:
parent
ca8c6fb072
commit
514819f37a
4 changed files with 16 additions and 13 deletions
|
@ -27,7 +27,7 @@ use msg::constellation_msg::PipelineId;
|
|||
use net_traits::{CoreResourceThread, ResourceThreads, IpcSend};
|
||||
use profile_traits::{mem, time};
|
||||
use script_runtime::{ScriptChan, maybe_take_panic_result};
|
||||
use script_thread::MainThreadScriptChan;
|
||||
use script_thread::{MainThreadScriptChan, RunnableWrapper};
|
||||
use script_traits::{MsDuration, ScriptMsg as ConstellationMsg, TimerEvent};
|
||||
use script_traits::{TimerEventId, TimerEventRequest, TimerSource};
|
||||
use std::cell::Cell;
|
||||
|
@ -396,6 +396,18 @@ impl GlobalScope {
|
|||
}
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
/// Returns a wrapper for runnables to ensure they are cancelled if
|
||||
/// the global scope is being destroyed.
|
||||
pub fn get_runnable_wrapper(&self) -> RunnableWrapper {
|
||||
if let Some(window) = self.downcast::<Window>() {
|
||||
return window.get_runnable_wrapper();
|
||||
}
|
||||
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
||||
return worker.get_runnable_wrapper();
|
||||
}
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
|
||||
fn timestamp_in_ms(time: Timespec) -> u64 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue