blob: 3cb790063a97868d1d47018684677b1331f64bac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
/*
This is a test case for Issue 507.
https://github.com/graydon/rust/issues/507
*/
use std;
import task;
import task::join;
import comm;
import comm::chan;
import comm::send;
import comm::port;
import comm::recv;
fn grandchild(c: chan<int>) { send(c, 42); }
fn child(c: chan<int>) {
let _grandchild = task::spawn_joinable {|| grandchild(c); };
join(_grandchild);
}
fn main() {
let p = comm::port();
let ch = chan(p);
let _child = task::spawn_joinable {|| child(ch); };
let x: int = recv(p);
log(debug, x);
assert (x == 42);
join(_child);
}
|