Pass the WorkQueue to LayoutTask::solve_constraints_parallel.

This removes the possibility of a panic by checking a constraint at compile
time rather than at run time.
This commit is contained in:
Ms2ger 2015-07-09 11:15:53 +02:00
parent 9e02ef9347
commit 17888045bd

View file

@ -757,23 +757,18 @@ impl LayoutTask {
/// benchmarked against those two. It is marked `#[inline(never)]` to aid profiling. /// benchmarked against those two. It is marked `#[inline(never)]` to aid profiling.
#[inline(never)] #[inline(never)]
fn solve_constraints_parallel(&self, fn solve_constraints_parallel(&self,
rw_data: &mut LayoutTaskData, traversal: &mut WorkQueue<SharedLayoutContext, WorkQueueData>,
layout_root: &mut FlowRef, layout_root: &mut FlowRef,
shared_layout_context: &SharedLayoutContext) { shared_layout_context: &SharedLayoutContext) {
let _scope = layout_debug_scope!("solve_constraints_parallel"); let _scope = layout_debug_scope!("solve_constraints_parallel");
match rw_data.parallel_traversal { // NOTE: this currently computes borders, so any pruning should separate that
None => panic!("solve_contraints_parallel() called with no parallel traversal ready"), // operation out.
Some(ref mut traversal) => { parallel::traverse_flow_tree_preorder(layout_root,
// NOTE: this currently computes borders, so any pruning should separate that self.profiler_metadata(),
// operation out. self.time_profiler_chan.clone(),
parallel::traverse_flow_tree_preorder(layout_root, shared_layout_context,
self.profiler_metadata(), traversal);
self.time_profiler_chan.clone(),
shared_layout_context,
traversal);
}
}
} }
/// Verifies that every node was either marked as a leaf or as a nonleaf in the flow tree. /// Verifies that every node was either marked as a leaf or as a nonleaf in the flow tree.
@ -1152,9 +1147,9 @@ impl LayoutTask {
// Sequential mode. // Sequential mode.
self.solve_constraints(&mut root_flow, &layout_context) self.solve_constraints(&mut root_flow, &layout_context)
} }
Some(_) => { Some(ref mut parallel) => {
// Parallel mode. // Parallel mode.
self.solve_constraints_parallel(rw_data, self.solve_constraints_parallel(parallel,
&mut root_flow, &mut root_flow,
&mut *layout_context); &mut *layout_context);
} }