Skip to content

Commit f76a462

Browse files
committed
Convert pfib to pipes. This is a useful stress test.
1 parent 1d04b0e commit f76a462

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/test/bench/shootout-pfib.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,33 @@ use std;
1515
import std::{time, getopts};
1616
import io::writer_util;
1717
import int::range;
18-
import comm::port;
19-
import comm::chan;
20-
import comm::send;
21-
import comm::recv;
18+
import pipes::port;
19+
import pipes::chan;
20+
import pipes::send;
21+
import pipes::recv;
2222

2323
import core::result;
2424
import result::{ok, err};
2525

2626
fn fib(n: int) -> int {
2727
fn pfib(c: chan<int>, n: int) {
2828
if n == 0 {
29-
send(c, 0);
29+
c.send(0);
3030
} else if n <= 2 {
31-
send(c, 1);
31+
c.send(1);
3232
} else {
33-
let p = port();
34-
let ch = chan(p);
33+
let p = pipes::port_set();
34+
let ch = p.chan();
3535
task::spawn(|| pfib(ch, n - 1) );
36+
let ch = p.chan();
3637
task::spawn(|| pfib(ch, n - 2) );
37-
send(c, recv(p) + recv(p));
38+
c.send(p.recv() + p.recv());
3839
}
3940
}
4041

41-
let p = port();
42-
let ch = chan(p);
42+
let (ch, p) = pipes::stream();
4343
let t = task::spawn(|| pfib(ch, n) );
44-
return recv(p);
44+
p.recv()
4545
}
4646

4747
type config = {stress: bool};

0 commit comments

Comments
 (0)