Auto merge of #6605 - Ms2ger:solve_constraints_parallel, r=SimonSapin

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.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6605)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-07-12 02:44:04 -06:00
commit d7cf58d6f1

View file

@ -757,14 +757,11 @@ 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 {
None => panic!("solve_contraints_parallel() called with no parallel traversal ready"),
Some(ref mut traversal) => {
// NOTE: this currently computes borders, so any pruning should separate that // NOTE: this currently computes borders, so any pruning should separate that
// operation out. // operation out.
parallel::traverse_flow_tree_preorder(layout_root, parallel::traverse_flow_tree_preorder(layout_root,
@ -773,8 +770,6 @@ impl LayoutTask {
shared_layout_context, shared_layout_context,
traversal); 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.
/// This is only on in debug builds. /// This is only on in debug builds.
@ -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);
} }