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

40 lines
671 B
Rust
Raw Normal View History

// Issue #763
use std;
import task;
import comm::chan;
import comm::send;
import comm;
import comm::port;
import comm::recv;
enum request { quit, close(chan<bool>), }
type ctx = chan<request>;
2011-10-20 22:34:04 -05:00
fn request_task(c: chan<ctx>) {
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 {
let p = port();
2012-01-04 23:14:53 -06:00
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();
let p = port::<bool>();
send(cx, close(chan(p)));
send(cx, quit);
}