2011-07-28 20:01:27 -05:00
|
|
|
// Issue #763
|
|
|
|
|
|
|
|
use std;
|
|
|
|
import std::task;
|
2011-08-25 13:20:43 -05:00
|
|
|
import std::comm::chan;
|
2011-08-13 17:20:11 -05:00
|
|
|
import std::comm::send;
|
|
|
|
import std::comm;
|
2011-08-25 13:20:43 -05:00
|
|
|
import std::comm::port;
|
|
|
|
import std::comm::recv;
|
2011-07-28 20:01:27 -05:00
|
|
|
|
2011-08-25 13:20:43 -05:00
|
|
|
tag request { quit; close(chan<bool>); }
|
2011-07-28 20:01:27 -05:00
|
|
|
|
2011-08-25 13:20:43 -05:00
|
|
|
type ctx = chan<request>;
|
2011-07-28 20:01:27 -05:00
|
|
|
|
2011-10-20 22:34:04 -05:00
|
|
|
fn request_task(c: chan<ctx>) {
|
2011-08-25 13:20:43 -05:00
|
|
|
let p = port();
|
|
|
|
send(c, chan(p));
|
2011-07-28 20:01:27 -05:00
|
|
|
let req: request;
|
2011-08-25 13:20:43 -05:00
|
|
|
req = recv(p);
|
2011-07-28 20:01:27 -05:00
|
|
|
// Need to drop req before receiving it again
|
2011-08-25 13:20:43 -05:00
|
|
|
req = recv(p);
|
2011-07-28 20:01:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn new() -> ctx {
|
2011-08-25 13:20:43 -05:00
|
|
|
let p = port();
|
2011-10-13 23:23:07 -05:00
|
|
|
let t = task::spawn(chan(p), request_task);
|
2011-07-28 20:01:27 -05:00
|
|
|
let cx: ctx;
|
2011-08-25 13:20:43 -05:00
|
|
|
cx = recv(p);
|
2011-07-28 20:01:27 -05:00
|
|
|
ret cx;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let cx = new();
|
|
|
|
|
2011-08-25 13:20:43 -05:00
|
|
|
let p = port::<bool>();
|
|
|
|
send(cx, close(chan(p)));
|
2011-08-13 17:20:11 -05:00
|
|
|
send(cx, quit);
|
2011-07-28 20:01:27 -05:00
|
|
|
}
|