2012-12-10 19:32:48 -06:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2011-07-28 20:01:27 -05:00
|
|
|
// Issue #763
|
|
|
|
|
2012-12-13 15:05:22 -06:00
|
|
|
enum request { quit, close(core::comm::Chan<bool>), }
|
2011-07-28 20:01:27 -05:00
|
|
|
|
2012-12-13 15:05:22 -06:00
|
|
|
type ctx = core::comm::Chan<request>;
|
2011-07-28 20:01:27 -05:00
|
|
|
|
2012-12-13 15:05:22 -06:00
|
|
|
fn request_task(c: core::comm::Chan<ctx>) {
|
|
|
|
let p = core::comm::Port();
|
|
|
|
core::comm::send(c, core::comm::Chan(&p));
|
2012-03-22 10:39:41 -05:00
|
|
|
let mut req: request;
|
2012-12-13 15:05:22 -06:00
|
|
|
req = core::comm::recv(p);
|
2011-07-28 20:01:27 -05:00
|
|
|
// Need to drop req before receiving it again
|
2012-12-13 15:05:22 -06:00
|
|
|
req = core::comm::recv(p);
|
2011-07-28 20:01:27 -05:00
|
|
|
}
|
|
|
|
|
2012-03-14 14:16:46 -05:00
|
|
|
fn new_cx() -> ctx {
|
2012-12-13 15:05:22 -06:00
|
|
|
let p = core::comm::Port();
|
|
|
|
let ch = core::comm::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;
|
2012-12-13 15:05:22 -06:00
|
|
|
cx = core::comm::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-12-13 15:05:22 -06:00
|
|
|
let p = core::comm::Port::<bool>();
|
|
|
|
core::comm::send(cx, close(core::comm::Chan(&p)));
|
|
|
|
core::comm::send(cx, quit);
|
2011-07-28 20:01:27 -05:00
|
|
|
}
|