mirror of
https://github.com/servo/servo.git
synced 2025-08-12 00:45:33 +01:00
Move timers to GlobalScope
This commit is contained in:
parent
5d8979237b
commit
991801488c
8 changed files with 144 additions and 145 deletions
|
@ -20,9 +20,7 @@ use js::jsapi::{CurrentGlobalOrNull, GetGlobalForObjectCrossCompartment};
|
|||
use js::jsapi::{JSContext, JSObject, JS_GetClass};
|
||||
use script_runtime::{CommonScriptMsg, EnqueuedPromiseCallback, ScriptChan, ScriptPort};
|
||||
use script_thread::{RunnableWrapper, ScriptThread};
|
||||
use script_traits::MsDuration;
|
||||
use task_source::file_reading::FileReadingTaskSource;
|
||||
use timers::{OneshotTimerCallback, OneshotTimerHandle};
|
||||
|
||||
/// A freely-copyable reference to a rooted global object.
|
||||
#[derive(Copy, Clone)]
|
||||
|
@ -87,26 +85,6 @@ impl<'a> GlobalRef<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Schedule the given `callback` to be invoked after at least `duration` milliseconds have
|
||||
/// passed.
|
||||
pub fn schedule_callback(&self,
|
||||
callback: OneshotTimerCallback,
|
||||
duration: MsDuration)
|
||||
-> OneshotTimerHandle {
|
||||
match *self {
|
||||
GlobalRef::Window(window) => window.schedule_callback(callback, duration),
|
||||
GlobalRef::Worker(worker) => worker.schedule_callback(callback, duration),
|
||||
}
|
||||
}
|
||||
|
||||
/// Unschedule a previously-scheduled callback.
|
||||
pub fn unschedule_callback(&self, handle: OneshotTimerHandle) {
|
||||
match *self {
|
||||
GlobalRef::Window(window) => window.unschedule_callback(handle),
|
||||
GlobalRef::Worker(worker) => worker.unschedule_callback(handle),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a wrapper for runnables to ensure they are cancelled if the global
|
||||
/// is being destroyed.
|
||||
pub fn get_runnable_wrapper(&self) -> RunnableWrapper {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue