File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change 1
1
// xfail-test
2
- io fn main ( ) {
3
- let port < int > po = port ( ) ;
2
+ use std;
3
+ import std:: comm;
4
+ import std:: task;
5
+
6
+ fn main ( ) {
7
+ let po = comm:: port ( ) ;
4
8
5
9
// Spawn 10 tasks each sending us back one int.
6
- let int i = 10 ;
10
+ let i = 10 ;
7
11
while ( i > 0 ) {
8
12
log i;
9
- spawn " child" child ( i, chan ( po) ) ;
13
+ task :: spawn ( bind child ( i, comm :: chan ( po) ) ) ;
10
14
i = i - 1 ;
11
15
}
12
16
13
17
// Spawned tasks are likely killed before they get a chance to send
14
18
// anything back, so we deadlock here.
15
19
16
20
i = 10 ;
17
- let int value = 0 ;
21
+ let value = 0 ;
18
22
while ( i > 0 ) {
19
23
log i;
20
- po |> value ;
24
+ value = comm :: recv ( po ) ;
21
25
i = i - 1 ;
22
26
}
23
27
24
28
log "main thread exiting" ;
25
29
}
26
30
27
- io fn child ( int x , chan < int > ch ) {
31
+ fn child ( x : int , ch : comm :: chan < int > ) {
28
32
log x;
29
- ch <| x ;
33
+ comm :: send ( ch , x ) ;
30
34
}
You can’t perform that action at this time.
0 commit comments