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-08-25 13:20:43 -05:00
|
|
|
fn request_task(c: chan<ctx>) {
|
|
|
|
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();
|
|
|
|
let t = task::spawn(bind request_task(chan(p)));
|
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
|
|
|
}
|