mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Rename Runnable to Task
The changes are: * `*Runnable` -> `*Task`; * `RunnableMsg` -> `Task`; * `RunnableWrapper` -> `TaskCanceller`; * `MainThreadRunnable` -> `MainThreadTask`; * `wrap_runnable` -> `wrap_task`; * `get_runnable_wrapper` -> `task_canceller`; * `handler` -> `run`; * `main_thread_handler` -> `run_with_script_thread`.
This commit is contained in:
parent
52a6f63608
commit
56117d3185
38 changed files with 370 additions and 332 deletions
|
@ -10,25 +10,25 @@ use dom::bindings::refcounted::Trusted;
|
|||
use dom::globalscope::GlobalScope;
|
||||
use dom::performance::Performance;
|
||||
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
|
||||
use script_thread::{Runnable, RunnableWrapper};
|
||||
use script_thread::{Task, TaskCanceller};
|
||||
use std::fmt;
|
||||
use std::result::Result;
|
||||
use task_source::TaskSource;
|
||||
|
||||
pub struct NotifyPerformanceObserverRunnable {
|
||||
pub struct NotifyPerformanceObserverTask {
|
||||
owner: Trusted<Performance>,
|
||||
}
|
||||
|
||||
impl NotifyPerformanceObserverRunnable {
|
||||
impl NotifyPerformanceObserverTask {
|
||||
pub fn new(owner: Trusted<Performance>) -> Self {
|
||||
NotifyPerformanceObserverRunnable {
|
||||
NotifyPerformanceObserverTask {
|
||||
owner,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Runnable for NotifyPerformanceObserverRunnable {
|
||||
fn handler(self: Box<NotifyPerformanceObserverRunnable>) {
|
||||
impl Task for NotifyPerformanceObserverTask {
|
||||
fn run(self: Box<Self>) {
|
||||
self.owner.root().notify_observers();
|
||||
}
|
||||
}
|
||||
|
@ -49,13 +49,17 @@ impl fmt::Debug for PerformanceTimelineTaskSource {
|
|||
}
|
||||
|
||||
impl TaskSource for PerformanceTimelineTaskSource {
|
||||
fn queue_with_wrapper<T>(&self,
|
||||
msg: Box<T>,
|
||||
wrapper: &RunnableWrapper) -> Result<(), ()>
|
||||
where T: Runnable + Send + 'static {
|
||||
let msg = CommonScriptMsg::RunnableMsg(
|
||||
fn queue_with_canceller<T>(
|
||||
&self,
|
||||
msg: Box<T>,
|
||||
canceller: &TaskCanceller,
|
||||
) -> Result<(), ()>
|
||||
where
|
||||
T: Send + Task + 'static,
|
||||
{
|
||||
let msg = CommonScriptMsg::Task(
|
||||
ScriptThreadEventCategory::PerformanceTimelineTask,
|
||||
wrapper.wrap_runnable(msg)
|
||||
canceller.wrap_task(msg)
|
||||
);
|
||||
self.0.send(msg).map_err(|_| ())
|
||||
}
|
||||
|
@ -64,7 +68,7 @@ impl TaskSource for PerformanceTimelineTaskSource {
|
|||
impl PerformanceTimelineTaskSource {
|
||||
pub fn queue_notification(&self, global: &GlobalScope) {
|
||||
let owner = Trusted::new(&*global.performance());
|
||||
let runnable = box NotifyPerformanceObserverRunnable::new(owner);
|
||||
let _ = self.queue(runnable, global);
|
||||
let task = box NotifyPerformanceObserverTask::new(owner);
|
||||
let _ = self.queue(task, global);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue