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-12-13 18:25:51 -06:00
|
|
|
import task;
|
|
|
|
import task::join;
|
|
|
|
import comm;
|
|
|
|
import comm::chan;
|
|
|
|
import comm::send;
|
|
|
|
import comm::port;
|
|
|
|
import comm::recv;
|
2011-06-16 16:47:59 -05:00
|
|
|
|
2011-10-20 22:34:04 -05:00
|
|
|
fn grandchild(c: chan<int>) { send(c, 42); }
|
2011-06-16 16:47:59 -05:00
|
|
|
|
2011-10-20 22:34:04 -05:00
|
|
|
fn child(c: chan<int>) {
|
2011-11-03 04:57:54 -05:00
|
|
|
let _grandchild = task::spawn_joinable(copy c, grandchild);
|
2011-08-25 13:20:43 -05:00
|
|
|
join(_grandchild);
|
2011-06-16 16:47:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2011-08-25 13:20:43 -05:00
|
|
|
let p = comm::port();
|
2011-06-16 16:47:59 -05:00
|
|
|
|
2011-10-13 23:23:07 -05:00
|
|
|
let _child = task::spawn_joinable(chan(p), child);
|
2011-07-13 17:44:09 -05:00
|
|
|
|
2011-08-25 13:20:43 -05:00
|
|
|
let x: int = recv(p);
|
2011-06-16 16:47:59 -05:00
|
|
|
|
2011-12-22 16:42:52 -06:00
|
|
|
log_full(core::debug, 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-25 13:20:43 -05:00
|
|
|
join(_child);
|
2011-08-10 11:27:22 -05:00
|
|
|
}
|