2011-07-28 20:01:27 -05:00
|
|
|
// Issue #763
|
|
|
|
|
2012-09-11 19:46:20 -05:00
|
|
|
extern mod std;
|
2012-09-05 14:32:05 -05:00
|
|
|
use comm::Chan;
|
|
|
|
use comm::send;
|
|
|
|
use comm::Port;
|
|
|
|
use comm::recv;
|
2011-07-28 20:01:27 -05:00
|
|
|
|
2012-08-15 16:10:46 -05:00
|
|
|
enum request { quit, close(Chan<bool>), }
|
2011-07-28 20:01:27 -05:00
|
|
|
|
2012-08-15 16:10:46 -05:00
|
|
|
type ctx = Chan<request>;
|
2011-07-28 20:01:27 -05:00
|
|
|
|
2012-08-15 16:10:46 -05:00
|
|
|
fn request_task(c: Chan<ctx>) {
|
2012-08-27 16:22:25 -05:00
|
|
|
let p = Port();
|
|
|
|
send(c, Chan(p));
|
2012-03-22 10:39:41 -05:00
|
|
|
let mut 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
|
|
|
}
|
|
|
|
|
2012-03-14 14:16:46 -05:00
|
|
|
fn new_cx() -> ctx {
|
2012-08-27 16:22:25 -05:00
|
|
|
let p = Port();
|
|
|
|
let ch = Chan(p);
|
2012-06-30 18:19:07 -05:00
|
|
|
let t = task::spawn(|| request_task(ch) );
|
2012-03-22 10:39:41 -05:00
|
|
|
let mut cx: ctx;
|
2011-08-25 13:20:43 -05:00
|
|
|
cx = recv(p);
|
2012-08-01 19:30:05 -05:00
|
|
|
return cx;
|
2011-07-28 20:01:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2012-03-14 14:16:46 -05:00
|
|
|
let cx = new_cx();
|
2011-07-28 20:01:27 -05:00
|
|
|
|
2012-08-27 16:22:25 -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
|
|
|
}
|