2011-06-16 16:47:59 -05:00
|
|
|
|
2011-07-13 17:44:09 -05:00
|
|
|
/*
|
2011-06-16 16:47:59 -05:00
|
|
|
This is a test case for Issue 507.
|
|
|
|
|
|
|
|
https://github.com/graydon/rust/issues/507
|
|
|
|
*/
|
|
|
|
|
|
|
|
use std;
|
|
|
|
|
2011-08-13 17:20:11 -05:00
|
|
|
import std::task;
|
|
|
|
import std::task::join_id;
|
|
|
|
import std::comm;
|
|
|
|
import std::comm::_chan;
|
|
|
|
import std::comm::send;
|
2011-06-16 16:47:59 -05:00
|
|
|
|
2011-08-13 17:20:11 -05:00
|
|
|
fn grandchild(c: _chan[int]) { send(c, 42); }
|
2011-06-16 16:47:59 -05:00
|
|
|
|
2011-08-13 17:20:11 -05:00
|
|
|
fn child(c: _chan[int]) {
|
|
|
|
let _grandchild = task::_spawn(bind grandchild(c));
|
|
|
|
join_id(_grandchild);
|
2011-06-16 16:47:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2011-08-13 17:20:11 -05:00
|
|
|
let p = comm::mk_port();
|
2011-06-16 16:47:59 -05:00
|
|
|
|
2011-08-13 17:20:11 -05:00
|
|
|
let _child = task::_spawn(bind child(p.mk_chan()));
|
2011-07-13 17:44:09 -05:00
|
|
|
|
2011-08-13 17:20:11 -05:00
|
|
|
let x: int = p.recv();
|
2011-06-16 16:47:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
log x;
|
2011-06-16 16:47:59 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
assert (x == 42);
|
2011-06-16 16:47:59 -05:00
|
|
|
|
2011-08-13 17:20:11 -05:00
|
|
|
join_id(_child);
|
2011-07-27 07:19:39 -05:00
|
|
|
}
|