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;
|
2011-08-25 13:20:43 -05:00
|
|
|
import std::task::join;
|
2011-08-13 17:20:11 -05:00
|
|
|
import std::comm;
|
2011-08-25 13:20:43 -05:00
|
|
|
import std::comm::chan;
|
2011-08-13 17:20:11 -05:00
|
|
|
import std::comm::send;
|
2011-08-25 13:20:43 -05:00
|
|
|
import std::comm::port;
|
|
|
|
import std::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-10-13 23:23:07 -05:00
|
|
|
let _grandchild = task::spawn_joinable(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-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-25 13:20:43 -05:00
|
|
|
join(_child);
|
2011-08-10 11:27:22 -05:00
|
|
|
}
|