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