File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
branches/dist-snap/src/test/bench Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
8
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9
9
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10
- refs/heads/dist-snap: 6bd01d0ac804a5a839a4513907b5697e35c8ad2e
10
+ refs/heads/dist-snap: a3dd67ae9165ee87c98ba7e5585ce859fd3fbe68
11
11
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
12
12
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
Original file line number Diff line number Diff line change 5
5
//
6
6
// The filename is a song reference; google it in quotes.
7
7
8
- fn child_generation ( gens_left : uint ) {
8
+ fn child_generation( gens_left : uint , - c : pipes :: chan < ( ) > ) {
9
9
// This used to be O(n^2) in the number of generations that ever existed.
10
10
// With this code, only as many generations are alive at a time as tasks
11
11
// alive at a time,
12
+ let c = ~mut some ( c) ;
12
13
do task:: spawn_supervised {
14
+ let c = option : : swap_unwrap ( c) ;
13
15
if gens_left & 1 == 1 {
14
16
task:: yield ( ) ; // shake things up a bit
15
17
}
16
18
if gens_left > 0 {
17
- child_generation ( gens_left - 1 ) ; // recurse
19
+ child_generation ( gens_left - 1 , c) ; // recurse
20
+ } else {
21
+ c. send ( ( ) )
18
22
}
19
23
}
20
24
}
@@ -28,5 +32,9 @@ fn main(args: ~[~str]) {
28
32
copy args
29
33
} ;
30
34
31
- child_generation ( uint:: from_str ( args[ 1 ] ) . get ( ) ) ;
35
+ let ( c, p) = pipes:: stream ( ) ;
36
+ child_generation ( uint:: from_str ( args[ 1 ] ) . get ( ) , c) ;
37
+ if p. try_recv ( ) . is_none ( ) {
38
+ fail ~"it happened when we slumbered";
39
+ }
32
40
}
You can’t perform that action at this time.
0 commit comments