File tree Expand file tree Collapse file tree 2 files changed +23
-14
lines changed
branches/dist-snap/src/libcore/rt Expand file tree Collapse file tree 2 files changed +23
-14
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
8
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9
9
refs/heads/incoming: b50030718cf28f2a5a81857a26b57442734fe854
10
- refs/heads/dist-snap: f03c9bd08cde6c83306d91bb07c4810b8b8f13ba
10
+ refs/heads/dist-snap: ee06ed2bfd233b57c5989696bb723bddf6569622
11
11
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
12
12
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
13
13
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
Original file line number Diff line number Diff line change 11
11
use container:: Container ;
12
12
use option:: * ;
13
13
use vec:: OwnedVector ;
14
+ use unstable:: sync:: { Exclusive , exclusive} ;
15
+ use cell:: Cell ;
16
+ use kinds:: Owned ;
14
17
15
18
pub struct WorkQueue < T > {
16
- priv queue : ~[ T ]
19
+ // XXX: Another mystery bug fixed by boxing this lock
20
+ priv queue : ~Exclusive < ~[ T ] >
17
21
}
18
22
19
- pub impl < T > WorkQueue < T > {
23
+ pub impl < T : Owned > WorkQueue < T > {
20
24
fn new ( ) -> WorkQueue < T > {
21
25
WorkQueue {
22
- queue : ~[ ]
26
+ queue : ~exclusive ( ~ [ ] )
23
27
}
24
28
}
25
29
26
30
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 ( ) ) ) ;
28
33
}
29
34
30
35
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
+ }
35
42
}
36
43
}
37
44
38
45
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
+ }
43
52
}
44
53
}
45
54
46
55
fn is_empty ( & self ) -> bool {
47
- return self . queue . is_empty ( ) ;
56
+ self . queue . with_imm ( |q| q . is_empty ( ) )
48
57
}
49
58
}
You can’t perform that action at this time.
0 commit comments