mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
introduce "per task source" ignoring of tasks
This commit is contained in:
parent
ce430566cd
commit
671627e97e
21 changed files with 127 additions and 34 deletions
|
@ -15,7 +15,7 @@ use std::fmt;
|
|||
use std::result::Result;
|
||||
use std::sync::mpsc::Sender;
|
||||
use task::{TaskCanceller, TaskOnce};
|
||||
use task_source::TaskSource;
|
||||
use task_source::{TaskSource, TaskSourceName};
|
||||
|
||||
#[derive(Clone, JSTraceable)]
|
||||
pub struct DOMManipulationTaskSource(pub Sender<MainThreadScriptMsg>, pub PipelineId);
|
||||
|
@ -27,6 +27,8 @@ impl fmt::Debug for DOMManipulationTaskSource {
|
|||
}
|
||||
|
||||
impl TaskSource for DOMManipulationTaskSource {
|
||||
const NAME: TaskSourceName = TaskSourceName::DOMManipulation;
|
||||
|
||||
fn queue_with_canceller<T>(
|
||||
&self,
|
||||
task: T,
|
||||
|
|
|
@ -8,7 +8,7 @@ use msg::constellation_msg::PipelineId;
|
|||
use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory, ScriptChan};
|
||||
use std::sync::Arc;
|
||||
use task::{TaskCanceller, TaskOnce};
|
||||
use task_source::TaskSource;
|
||||
use task_source::{TaskSource, TaskSourceName};
|
||||
|
||||
#[derive(JSTraceable)]
|
||||
pub struct FileReadingTaskSource(pub Box<ScriptChan + Send + 'static>, pub PipelineId);
|
||||
|
@ -20,6 +20,8 @@ impl Clone for FileReadingTaskSource {
|
|||
}
|
||||
|
||||
impl TaskSource for FileReadingTaskSource {
|
||||
const NAME: TaskSourceName = TaskSourceName::FileReading;
|
||||
|
||||
fn queue_with_canceller<T>(
|
||||
&self,
|
||||
task: T,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
pub mod dom_manipulation;
|
||||
pub mod file_reading;
|
||||
pub mod history_traversal;
|
||||
|
@ -10,10 +11,33 @@ pub mod performance_timeline;
|
|||
pub mod user_interaction;
|
||||
|
||||
use dom::globalscope::GlobalScope;
|
||||
use enum_iterator::IntoEnumIterator;
|
||||
use std::result::Result;
|
||||
use task::{TaskCanceller, TaskOnce};
|
||||
|
||||
// The names of all task sources, used to differentiate TaskCancellers.
|
||||
// Note: When adding a task source, update this enum.
|
||||
// Note: The HistoryTraversalTaskSource is not part of this,
|
||||
// because it doesn't implement TaskSource.
|
||||
#[derive(Eq, Hash, IntoEnumIterator, JSTraceable, PartialEq)]
|
||||
pub enum TaskSourceName {
|
||||
DOMManipulation,
|
||||
FileReading,
|
||||
HistoryTraversal,
|
||||
Networking,
|
||||
PerformanceTimeline,
|
||||
UserInteraction
|
||||
}
|
||||
|
||||
impl TaskSourceName {
|
||||
pub fn all() -> Vec<TaskSourceName> {
|
||||
TaskSourceName::into_enum_iter().collect()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait TaskSource {
|
||||
const NAME: TaskSourceName;
|
||||
|
||||
fn queue_with_canceller<T>(
|
||||
&self,
|
||||
task: T,
|
||||
|
@ -26,6 +50,7 @@ pub trait TaskSource {
|
|||
where
|
||||
T: TaskOnce + 'static,
|
||||
{
|
||||
self.queue_with_canceller(task, &global.task_canceller())
|
||||
let canceller = global.task_canceller(Self::NAME);
|
||||
self.queue_with_canceller(task, &canceller)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use msg::constellation_msg::PipelineId;
|
||||
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
|
||||
use task::{TaskCanceller, TaskOnce};
|
||||
use task_source::TaskSource;
|
||||
use task_source::{TaskSource, TaskSourceName};
|
||||
|
||||
#[derive(JSTraceable)]
|
||||
pub struct NetworkingTaskSource(pub Box<ScriptChan + Send + 'static>, pub PipelineId);
|
||||
|
@ -17,6 +17,8 @@ impl Clone for NetworkingTaskSource {
|
|||
}
|
||||
|
||||
impl TaskSource for NetworkingTaskSource {
|
||||
const NAME: TaskSourceName = TaskSourceName::Networking;
|
||||
|
||||
fn queue_with_canceller<T>(
|
||||
&self,
|
||||
task: T,
|
||||
|
|
|
@ -13,7 +13,7 @@ use script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
|
|||
use std::fmt;
|
||||
use std::result::Result;
|
||||
use task::{TaskCanceller, TaskOnce};
|
||||
use task_source::TaskSource;
|
||||
use task_source::{TaskSource, TaskSourceName};
|
||||
|
||||
#[derive(JSTraceable)]
|
||||
pub struct PerformanceTimelineTaskSource(pub Box<ScriptChan + Send + 'static>, pub PipelineId);
|
||||
|
@ -31,6 +31,8 @@ impl fmt::Debug for PerformanceTimelineTaskSource {
|
|||
}
|
||||
|
||||
impl TaskSource for PerformanceTimelineTaskSource {
|
||||
const NAME: TaskSourceName = TaskSourceName::PerformanceTimeline;
|
||||
|
||||
fn queue_with_canceller<T>(
|
||||
&self,
|
||||
task: T,
|
||||
|
|
|
@ -15,7 +15,7 @@ use std::fmt;
|
|||
use std::result::Result;
|
||||
use std::sync::mpsc::Sender;
|
||||
use task::{TaskCanceller, TaskOnce};
|
||||
use task_source::TaskSource;
|
||||
use task_source::{TaskSource, TaskSourceName};
|
||||
|
||||
#[derive(Clone, JSTraceable)]
|
||||
pub struct UserInteractionTaskSource(pub Sender<MainThreadScriptMsg>, pub PipelineId);
|
||||
|
@ -27,6 +27,8 @@ impl fmt::Debug for UserInteractionTaskSource {
|
|||
}
|
||||
|
||||
impl TaskSource for UserInteractionTaskSource {
|
||||
const NAME: TaskSourceName = TaskSourceName::UserInteraction;
|
||||
|
||||
fn queue_with_canceller<T>(
|
||||
&self,
|
||||
task: T,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue