File tree Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -15,33 +15,33 @@ use std;
15
15
import std:: { time, getopts} ;
16
16
import io:: writer_util;
17
17
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;
22
22
23
23
import core:: result;
24
24
import result:: { ok, err} ;
25
25
26
26
fn fib ( n : int ) -> int {
27
27
fn pfib ( c : chan < int > , n : int ) {
28
28
if n == 0 {
29
- send ( c , 0 ) ;
29
+ c . send ( 0 ) ;
30
30
} else if n <= 2 {
31
- send ( c , 1 ) ;
31
+ c . send ( 1 ) ;
32
32
} else {
33
- let p = port ( ) ;
34
- let ch = chan ( p ) ;
33
+ let p = pipes :: port_set ( ) ;
34
+ let ch = p . chan ( ) ;
35
35
task:: spawn ( || pfib ( ch, n - 1 ) ) ;
36
+ let ch = p. chan ( ) ;
36
37
task:: spawn ( || pfib ( ch, n - 2 ) ) ;
37
- send ( c , recv ( p ) + recv ( p ) ) ;
38
+ c . send ( p . recv ( ) + p . recv ( ) ) ;
38
39
}
39
40
}
40
41
41
- let p = port ( ) ;
42
- let ch = chan ( p) ;
42
+ let ( ch, p) = pipes:: stream ( ) ;
43
43
let t = task:: spawn ( || pfib ( ch, n) ) ;
44
- return recv ( p ) ;
44
+ p . recv ( )
45
45
}
46
46
47
47
type config = { stress : bool } ;
You can’t perform that action at this time.
0 commit comments