Auto merge of #6504 - Ms2ger:workqueue-labeled-break, r=pcwalton

Move back to using a labeled break in WorkQueue.

This was changed in 18a2050a64; it appears to
work fine now.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6504)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-07-03 06:39:53 -06:00
commit 59d3b45b74

View file

@ -114,20 +114,13 @@ impl<QueueData: Send, WorkData: Send> WorkerThread<QueueData, WorkData> {
let mut back_off_sleep = 0 as u32; let mut back_off_sleep = 0 as u32;
// We're off! // We're off!
// 'outer: loop {
// FIXME(pcwalton): Can't use labeled break or continue cross-crate due to a Rust bug. let work_unit;
loop {
// FIXME(pcwalton): Nasty workaround for the lack of labeled break/continue
// cross-crate.
let mut work_unit = unsafe {
mem::uninitialized()
};
match deque.pop() { match deque.pop() {
Some(work) => work_unit = work, Some(work) => work_unit = work,
None => { None => {
// Become a thief. // Become a thief.
let mut i = 0; let mut i = 0;
let mut should_continue = true;
loop { loop {
// Don't just use `rand % len` because that's slow on ARM. // Don't just use `rand % len` because that's slow on ARM.
let mut victim; let mut victim;
@ -153,10 +146,7 @@ impl<QueueData: Send, WorkData: Send> WorkerThread<QueueData, WorkData> {
if back_off_sleep >= BACKOFF_INCREMENT_IN_US * if back_off_sleep >= BACKOFF_INCREMENT_IN_US *
BACKOFFS_UNTIL_CONTROL_CHECK { BACKOFFS_UNTIL_CONTROL_CHECK {
match self.port.try_recv() { match self.port.try_recv() {
Ok(WorkerMsg::Stop) => { Ok(WorkerMsg::Stop) => break 'outer,
should_continue = false;
break
}
Ok(WorkerMsg::Exit) => return, Ok(WorkerMsg::Exit) => return,
Ok(_) => panic!("unexpected message"), Ok(_) => panic!("unexpected message"),
_ => {} _ => {}
@ -172,10 +162,6 @@ impl<QueueData: Send, WorkData: Send> WorkerThread<QueueData, WorkData> {
i += 1 i += 1
} }
} }
if !should_continue {
break
}
} }
} }