Skip to content

Commit a3dd67a

Browse files
committed
Make 100 generations perf test sensitive to spawn failures
1 parent 6bd01d0 commit a3dd67a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/test/bench/task-perf-jargon-metal-smoke.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
//
66
// The filename is a song reference; google it in quotes.
77

8-
fn child_generation(gens_left: uint) {
8+
fn child_generation(gens_left: uint, -c: pipes::chan<()>) {
99
// This used to be O(n^2) in the number of generations that ever existed.
1010
// With this code, only as many generations are alive at a time as tasks
1111
// alive at a time,
12+
let c = ~mut some(c);
1213
do task::spawn_supervised {
14+
let c = option::swap_unwrap(c);
1315
if gens_left & 1 == 1 {
1416
task::yield(); // shake things up a bit
1517
}
1618
if gens_left > 0 {
17-
child_generation(gens_left - 1); // recurse
19+
child_generation(gens_left - 1, c); // recurse
20+
} else {
21+
c.send(())
1822
}
1923
}
2024
}
@@ -28,5 +32,9 @@ fn main(args: ~[~str]) {
2832
copy args
2933
};
3034

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+
}
3240
}

0 commit comments

Comments
 (0)