Introduce TaskOnce

Having both TaskBox and TaskOnce allows us to remove the superfluous inner boxing
from CancellableTask<T>.
This commit is contained in:
Anthony Ramine 2017-09-20 10:37:09 +02:00
parent 52527d6f9d
commit 6c9fb5ae7a
26 changed files with 144 additions and 124 deletions

View file

@ -13,7 +13,7 @@ use servo_atoms::Atom;
use std::fmt;
use std::result::Result;
use std::sync::mpsc::Sender;
use task::{TaskBox, TaskCanceller};
use task::{TaskCanceller, TaskOnce};
use task_source::TaskSource;
#[derive(Clone, JSTraceable)]
@ -28,15 +28,15 @@ impl fmt::Debug for DOMManipulationTaskSource {
impl TaskSource for DOMManipulationTaskSource {
fn queue_with_canceller<T>(
&self,
msg: Box<T>,
task: T,
canceller: &TaskCanceller,
) -> Result<(), ()>
where
T: TaskBox + 'static,
T: TaskOnce + 'static,
{
let msg = MainThreadScriptMsg::Common(CommonScriptMsg::Task(
ScriptThreadEventCategory::ScriptEvent,
canceller.wrap_task(msg),
box canceller.wrap_task(task),
));
self.0.send(msg).map_err(|_| ())
}
@ -50,7 +50,7 @@ impl DOMManipulationTaskSource {
cancelable: EventCancelable,
window: &Window) {
let target = Trusted::new(target);
let task = box EventTask {
let task = EventTask {
target: target,
name: name,
bubbles: bubbles,
@ -61,6 +61,6 @@ impl DOMManipulationTaskSource {
pub fn queue_simple_event(&self, target: &EventTarget, name: Atom, window: &Window) {
let target = Trusted::new(target);
let _ = self.queue(box SimpleEventTask { target, name }, window.upcast());
let _ = self.queue(SimpleEventTask { target, name }, window.upcast());
}
}