mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +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
|
@ -40,7 +40,7 @@ use std::collections::HashMap;
|
|||
use std::rc::Rc;
|
||||
use std::str::FromStr;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use task::TaskBox;
|
||||
use task::TaskOnce;
|
||||
|
||||
const KEY_CONVERSION_ERROR: &'static str = "This `manufacturerData` key can not be parsed as unsigned short:";
|
||||
const FILTER_EMPTY_ERROR: &'static str = "'filters' member, if present, must be nonempty to find any devices.";
|
||||
|
@ -229,18 +229,17 @@ pub fn response_async<T: AsyncBluetoothListener + DomObject + 'static>(
|
|||
action: BluetoothResponseResult,
|
||||
}
|
||||
|
||||
impl<T> TaskBox for ListenerTask<T>
|
||||
impl<T> TaskOnce for ListenerTask<T>
|
||||
where
|
||||
T: AsyncBluetoothListener + DomObject,
|
||||
{
|
||||
fn run_box(self: Box<Self>) {
|
||||
let this = *self;
|
||||
let mut context = this.context.lock().unwrap();
|
||||
context.response(this.action);
|
||||
fn run_once(self) {
|
||||
let mut context = self.context.lock().unwrap();
|
||||
context.response(self.action);
|
||||
}
|
||||
}
|
||||
|
||||
let task = box ListenerTask {
|
||||
let task = ListenerTask {
|
||||
context: context.clone(),
|
||||
action: message.to().unwrap(),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue