mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Remove the data field from WorkQueue.
It is only used in the run method.
This commit is contained in:
parent
c214c03375
commit
41da4fceee
3 changed files with 5 additions and 15 deletions
|
@ -300,8 +300,7 @@ impl LayoutTask {
|
||||||
opts::get().initial_window_size.as_f32() * ScaleFactor::new(1.0));
|
opts::get().initial_window_size.as_f32() * ScaleFactor::new(1.0));
|
||||||
let parallel_traversal = if opts::get().layout_threads != 1 {
|
let parallel_traversal = if opts::get().layout_threads != 1 {
|
||||||
Some(WorkQueue::new("LayoutWorker", task_state::LAYOUT,
|
Some(WorkQueue::new("LayoutWorker", task_state::LAYOUT,
|
||||||
opts::get().layout_threads,
|
opts::get().layout_threads))
|
||||||
SharedLayoutContextWrapper(ptr::null())))
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,7 +21,6 @@ use wrapper::{PreorderDomTraversal, PostorderDomTraversal};
|
||||||
|
|
||||||
use profile_traits::time::{self, ProfilerMetadata, profile};
|
use profile_traits::time::{self, ProfilerMetadata, profile};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ptr;
|
|
||||||
use std::sync::atomic::{AtomicIsize, Ordering};
|
use std::sync::atomic::{AtomicIsize, Ordering};
|
||||||
use util::opts;
|
use util::opts;
|
||||||
use util::workqueue::{WorkQueue, WorkUnit, WorkerProxy};
|
use util::workqueue::{WorkQueue, WorkUnit, WorkerProxy};
|
||||||
|
@ -449,15 +448,11 @@ fn run_queue_with_custom_work_data_type<To,F>(
|
||||||
callback: F,
|
callback: F,
|
||||||
shared_layout_context: &SharedLayoutContext)
|
shared_layout_context: &SharedLayoutContext)
|
||||||
where To: 'static + Send, F: FnOnce(&mut WorkQueue<SharedLayoutContextWrapper,To>) {
|
where To: 'static + Send, F: FnOnce(&mut WorkQueue<SharedLayoutContextWrapper,To>) {
|
||||||
queue.data = SharedLayoutContextWrapper(shared_layout_context as *const _);
|
|
||||||
|
|
||||||
let queue: &mut WorkQueue<SharedLayoutContextWrapper,To> = unsafe {
|
let queue: &mut WorkQueue<SharedLayoutContextWrapper,To> = unsafe {
|
||||||
mem::transmute(queue)
|
mem::transmute(queue)
|
||||||
};
|
};
|
||||||
callback(queue);
|
callback(queue);
|
||||||
queue.run();
|
queue.run(SharedLayoutContextWrapper(shared_layout_context as *const _));
|
||||||
|
|
||||||
queue.data = SharedLayoutContextWrapper(ptr::null());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn traverse_dom_preorder(root: LayoutNode,
|
pub fn traverse_dom_preorder(root: LayoutNode,
|
||||||
|
|
|
@ -244,8 +244,6 @@ pub struct WorkQueue<QueueData: 'static, WorkData: 'static> {
|
||||||
port: Receiver<SupervisorMsg<QueueData, WorkData>>,
|
port: Receiver<SupervisorMsg<QueueData, WorkData>>,
|
||||||
/// The amount of work that has been enqueued.
|
/// The amount of work that has been enqueued.
|
||||||
work_count: usize,
|
work_count: usize,
|
||||||
/// Arbitrary user data.
|
|
||||||
pub data: QueueData,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<QueueData: Send, WorkData: Send> WorkQueue<QueueData, WorkData> {
|
impl<QueueData: Send, WorkData: Send> WorkQueue<QueueData, WorkData> {
|
||||||
|
@ -253,8 +251,7 @@ impl<QueueData: Send, WorkData: Send> WorkQueue<QueueData, WorkData> {
|
||||||
/// it.
|
/// it.
|
||||||
pub fn new(task_name: &'static str,
|
pub fn new(task_name: &'static str,
|
||||||
state: task_state::TaskState,
|
state: task_state::TaskState,
|
||||||
thread_count: usize,
|
thread_count: usize) -> WorkQueue<QueueData, WorkData> {
|
||||||
user_data: QueueData) -> WorkQueue<QueueData, WorkData> {
|
|
||||||
// Set up data structures.
|
// Set up data structures.
|
||||||
let (supervisor_chan, supervisor_port) = channel();
|
let (supervisor_chan, supervisor_port) = channel();
|
||||||
let (mut infos, mut threads) = (vec!(), vec!());
|
let (mut infos, mut threads) = (vec!(), vec!());
|
||||||
|
@ -302,7 +299,6 @@ impl<QueueData: Send, WorkData: Send> WorkQueue<QueueData, WorkData> {
|
||||||
workers: infos,
|
workers: infos,
|
||||||
port: supervisor_port,
|
port: supervisor_port,
|
||||||
work_count: 0,
|
work_count: 0,
|
||||||
data: user_data,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,13 +316,13 @@ impl<QueueData: Send, WorkData: Send> WorkQueue<QueueData, WorkData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Synchronously runs all the enqueued tasks and waits for them to complete.
|
/// Synchronously runs all the enqueued tasks and waits for them to complete.
|
||||||
pub fn run(&mut self) {
|
pub fn run(&mut self, data: QueueData) {
|
||||||
// Tell the workers to start.
|
// Tell the workers to start.
|
||||||
let mut work_count = AtomicUsize::new(self.work_count);
|
let mut work_count = AtomicUsize::new(self.work_count);
|
||||||
for worker in self.workers.iter_mut() {
|
for worker in self.workers.iter_mut() {
|
||||||
worker.chan.send(WorkerMsg::Start(worker.deque.take().unwrap(),
|
worker.chan.send(WorkerMsg::Start(worker.deque.take().unwrap(),
|
||||||
&mut work_count,
|
&mut work_count,
|
||||||
&self.data)).unwrap()
|
&data)).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for the work to finish.
|
// Wait for the work to finish.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue