rust/src/test/run-pass/chan-leak.rs

38 lines
640 B
Rust
Raw Normal View History

// Issue #763
extern mod std;
2012-09-05 14:32:05 -05:00
use comm::Chan;
use comm::send;
use comm::Port;
use comm::recv;
2012-08-15 16:10:46 -05:00
enum request { quit, close(Chan<bool>), }
2012-08-15 16:10:46 -05:00
type ctx = Chan<request>;
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));
let mut req: request;
req = recv(p);
// Need to drop req before receiving it again
req = recv(p);
}
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) );
let mut cx: ctx;
cx = recv(p);
2012-08-01 19:30:05 -05:00
return cx;
}
fn main() {
let cx = new_cx();
2012-08-27 16:22:25 -05:00
let p = Port::<bool>();
send(cx, close(Chan(p)));
send(cx, quit);
}