aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/task_queue.rs
diff options
context:
space:
mode:
authorAgustin Chiappe Berrini <jnieve@gmail.com>2018-09-02 08:18:22 -0400
committerAgustinCB <jnieve@gmail.com>2018-09-04 09:17:11 -0400
commite286fdcc536df0cae9020a677380ffe2fa494566 (patch)
treef9bcfc3d8283f1bc015adfa4249d9276d69088cb /components/script/task_queue.rs
parentb211e45bb0106127edbedb31cb36209da3934eeb (diff)
downloadservo-e286fdcc536df0cae9020a677380ffe2fa494566.tar.gz
servo-e286fdcc536df0cae9020a677380ffe2fa494566.zip
Add the TaskSourceName to CommonScriptMsg::Task
Update QueuedTaskConversion and the TaskQueue to use it
Diffstat (limited to 'components/script/task_queue.rs')
-rw-r--r--components/script/task_queue.rs31
1 files changed, 16 insertions, 15 deletions
diff --git a/components/script/task_queue.rs b/components/script/task_queue.rs
index df72bb9a069..7093474e1ed 100644
--- a/components/script/task_queue.rs
+++ b/components/script/task_queue.rs
@@ -16,11 +16,17 @@ use task::TaskBox;
use task_source::TaskSourceName;
-pub type QueuedTask = (Option<TrustedWorkerAddress>, ScriptThreadEventCategory, Box<TaskBox>, Option<PipelineId>);
+pub type QueuedTask = (
+ Option<TrustedWorkerAddress>,
+ ScriptThreadEventCategory,
+ Box<TaskBox>,
+ Option<PipelineId>,
+ TaskSourceName
+);
/// Defining the operations used to convert from a msg T to a QueuedTask.
pub trait QueuedTaskConversion {
- fn task_category(&self) -> Option<&ScriptThreadEventCategory>;
+ fn task_source_name(&self) -> Option<&TaskSourceName>;
fn into_queued_task(self) -> Option<QueuedTask>;
fn from_queued_task(queued_task: QueuedTask) -> Self;
fn wake_up_msg() -> Self;
@@ -60,12 +66,12 @@ impl<T: QueuedTaskConversion> TaskQueue<T> {
.collect();
let to_be_throttled: Vec<T> = non_throttled.drain_filter(|msg|{
- let category = match msg.task_category() {
- Some(category) => category,
+ let task_source = match msg.task_source_name() {
+ Some(task_source) => task_source,
None => return false,
};
- match category {
- ScriptThreadEventCategory::PerformanceTimelineTask => return true,
+ match task_source {
+ TaskSourceName::PerformanceTimeline => return true,
_ => {
// A task that will not be throttled, start counting "business"
self.taken_task_counter.set(self.taken_task_counter.get() + 1);
@@ -81,20 +87,15 @@ impl<T: QueuedTaskConversion> TaskQueue<T> {
for msg in to_be_throttled {
// Categorize tasks per task queue.
- let (worker, category, boxed, pipeline_id) = match msg.into_queued_task() {
- Some((worker, category, boxed, pipeline_id)) => (worker, category, boxed, pipeline_id),
+ let (worker, category, boxed, pipeline_id, task_source) = match msg.into_queued_task() {
+ Some(queued_task) => queued_task,
None => unreachable!("A message to be throttled should always be convertible into a queued task"),
};
- // FIXME: Add the task-source name directly to CommonScriptMsg::Task.
- let task_source = match category {
- ScriptThreadEventCategory::PerformanceTimelineTask => TaskSourceName::PerformanceTimeline,
- _ => unreachable!(),
- };
let mut throttled_tasks = self.throttled.borrow_mut();
throttled_tasks
- .entry(task_source)
+ .entry(task_source.clone())
.or_insert(VecDeque::new())
- .push_back((worker, category, boxed, pipeline_id));
+ .push_back((worker, category, boxed, pipeline_id, task_source));
}
}