Skip to content

Commit c6d460d

Browse files
committed
Rehabilitate task-comm-14
1 parent 564bdac commit c6d460d

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
// 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();
48

59
// Spawn 10 tasks each sending us back one int.
6-
let int i = 10;
10+
let i = 10;
711
while (i > 0) {
812
log i;
9-
spawn "child" child(i, chan(po));
13+
task::spawn(bind child(i, comm::chan(po)));
1014
i = i - 1;
1115
}
1216

1317
// Spawned tasks are likely killed before they get a chance to send
1418
// anything back, so we deadlock here.
1519

1620
i = 10;
17-
let int value = 0;
21+
let value = 0;
1822
while (i > 0) {
1923
log i;
20-
po |> value;
24+
value = comm::recv(po);
2125
i = i - 1;
2226
}
2327

2428
log "main thread exiting";
2529
}
2630

27-
io fn child(int x, chan<int> ch) {
31+
fn child(x: int, ch: comm::chan<int>) {
2832
log x;
29-
ch <| x;
33+
comm::send(ch, x);
3034
}

0 commit comments

Comments
 (0)