Skip to content

Commit 490fa15

Browse files
committed
---
yaml --- r: 60554 b: refs/heads/auto c: ee06ed2 h: refs/heads/master v: v3
1 parent be09753 commit 490fa15

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: f03c9bd08cde6c83306d91bb07c4810b8b8f13ba
17+
refs/heads/auto: ee06ed2bfd233b57c5989696bb723bddf6569622
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/libcore/rt/work_queue.rs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,48 @@
1111
use container::Container;
1212
use option::*;
1313
use vec::OwnedVector;
14+
use unstable::sync::{Exclusive, exclusive};
15+
use cell::Cell;
16+
use kinds::Owned;
1417

1518
pub struct WorkQueue<T> {
16-
priv queue: ~[T]
19+
// XXX: Another mystery bug fixed by boxing this lock
20+
priv queue: ~Exclusive<~[T]>
1721
}
1822

19-
pub impl<T> WorkQueue<T> {
23+
pub impl<T: Owned> WorkQueue<T> {
2024
fn new() -> WorkQueue<T> {
2125
WorkQueue {
22-
queue: ~[]
26+
queue: ~exclusive(~[])
2327
}
2428
}
2529

2630
fn push(&mut self, value: T) {
27-
self.queue.unshift(value)
31+
let value = Cell(value);
32+
self.queue.with(|q| q.unshift(value.take()) );
2833
}
2934

3035
fn pop(&mut self) -> Option<T> {
31-
if !self.queue.is_empty() {
32-
Some(self.queue.shift())
33-
} else {
34-
None
36+
do self.queue.with |q| {
37+
if !q.is_empty() {
38+
Some(q.shift())
39+
} else {
40+
None
41+
}
3542
}
3643
}
3744

3845
fn steal(&mut self) -> Option<T> {
39-
if !self.queue.is_empty() {
40-
Some(self.queue.pop())
41-
} else {
42-
None
46+
do self.queue.with |q| {
47+
if !q.is_empty() {
48+
Some(q.pop())
49+
} else {
50+
None
51+
}
4352
}
4453
}
4554

4655
fn is_empty(&self) -> bool {
47-
return self.queue.is_empty();
56+
self.queue.with_imm(|q| q.is_empty() )
4857
}
4958
}

0 commit comments

Comments
 (0)