mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Reduce the amount of code in the unsafe block in ParallelPostorderFlowTraversal::run_parallel.
This commit is contained in:
parent
46b36242a3
commit
5d36fbca29
1 changed files with 31 additions and 29 deletions
|
@ -242,41 +242,43 @@ trait ParallelPostorderFlowTraversal : PostorderFlowTraversal {
|
||||||
mut unsafe_flow: UnsafeFlow,
|
mut unsafe_flow: UnsafeFlow,
|
||||||
_: &mut WorkerProxy<SharedLayoutContext,UnsafeFlowList>) {
|
_: &mut WorkerProxy<SharedLayoutContext,UnsafeFlowList>) {
|
||||||
loop {
|
loop {
|
||||||
unsafe {
|
// Get a real flow.
|
||||||
// Get a real flow.
|
let flow: &mut FlowRef = unsafe {
|
||||||
let flow: &mut FlowRef = mem::transmute(&mut unsafe_flow);
|
mem::transmute(&mut unsafe_flow)
|
||||||
|
};
|
||||||
|
|
||||||
// Perform the appropriate traversal.
|
// Perform the appropriate traversal.
|
||||||
if self.should_process(&mut **flow) {
|
if self.should_process(&mut **flow) {
|
||||||
self.process(&mut **flow);
|
self.process(&mut **flow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let base = flow::mut_base(&mut **flow);
|
let base = flow::mut_base(&mut **flow);
|
||||||
|
|
||||||
// Reset the count of children for the next layout traversal.
|
// Reset the count of children for the next layout traversal.
|
||||||
base.parallel.children_count.store(base.children.len() as isize,
|
base.parallel.children_count.store(base.children.len() as isize,
|
||||||
Ordering::Relaxed);
|
Ordering::Relaxed);
|
||||||
|
|
||||||
// Possibly enqueue the parent.
|
// Possibly enqueue the parent.
|
||||||
let mut unsafe_parent = base.parallel.parent;
|
let mut unsafe_parent = base.parallel.parent;
|
||||||
if unsafe_parent == null_unsafe_flow() {
|
if unsafe_parent == null_unsafe_flow() {
|
||||||
// We're done!
|
// We're done!
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
// No, we're not at the root yet. Then are we the last child
|
// No, we're not at the root yet. Then are we the last child
|
||||||
// of our parent to finish processing? If so, we can continue
|
// of our parent to finish processing? If so, we can continue
|
||||||
// on with our parent; otherwise, we've gotta wait.
|
// on with our parent; otherwise, we've gotta wait.
|
||||||
let parent: &mut FlowRef = mem::transmute(&mut unsafe_parent);
|
let parent: &mut FlowRef = unsafe {
|
||||||
let parent_base = flow::mut_base(&mut **parent);
|
mem::transmute(&mut unsafe_parent)
|
||||||
if parent_base.parallel.children_count.fetch_sub(1, Ordering::Relaxed) == 1 {
|
};
|
||||||
// We were the last child of our parent. Reflow our parent.
|
let parent_base = flow::mut_base(&mut **parent);
|
||||||
unsafe_flow = unsafe_parent
|
if parent_base.parallel.children_count.fetch_sub(1, Ordering::Relaxed) == 1 {
|
||||||
} else {
|
// We were the last child of our parent. Reflow our parent.
|
||||||
// Stop.
|
unsafe_flow = unsafe_parent
|
||||||
break
|
} else {
|
||||||
}
|
// Stop.
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue