mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Introduce TaskOnce
Having both TaskBox and TaskOnce allows us to remove the superfluous inner boxing from CancellableTask<T>.
This commit is contained in:
parent
52527d6f9d
commit
6c9fb5ae7a
26 changed files with 144 additions and 124 deletions
|
@ -6,7 +6,7 @@ use dom::domexception::DOMErrorName;
|
|||
use dom::filereader::{FileReader, TrustedFileReader, GenerationId, ReadMetaData};
|
||||
use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory, ScriptChan};
|
||||
use std::sync::Arc;
|
||||
use task::{TaskBox, TaskCanceller};
|
||||
use task::{TaskCanceller, TaskOnce};
|
||||
use task_source::TaskSource;
|
||||
|
||||
#[derive(JSTraceable)]
|
||||
|
@ -21,21 +21,21 @@ impl Clone for FileReadingTaskSource {
|
|||
impl TaskSource for FileReadingTaskSource {
|
||||
fn queue_with_canceller<T>(
|
||||
&self,
|
||||
msg: Box<T>,
|
||||
task: T,
|
||||
canceller: &TaskCanceller,
|
||||
) -> Result<(), ()>
|
||||
where
|
||||
T: TaskBox + 'static,
|
||||
T: TaskOnce + 'static,
|
||||
{
|
||||
self.0.send(CommonScriptMsg::Task(
|
||||
ScriptThreadEventCategory::FileRead,
|
||||
canceller.wrap_task(msg),
|
||||
box canceller.wrap_task(task),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TaskBox for FileReadingTask {
|
||||
fn run_box(self: Box<Self>) {
|
||||
impl TaskOnce for FileReadingTask {
|
||||
fn run_once(self) {
|
||||
self.handle_task();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue