2011-06-15 11:19:50 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-03-25 12:19:20 -07:00
|
|
|
// xfail-stage0
|
2011-05-03 18:13:51 -07:00
|
|
|
// xfail-stage1
|
|
|
|
// xfail-stage2
|
2011-06-15 11:19:50 -07:00
|
|
|
obj worker(chan[int] c) {drop { log "in dtor"; c <| 10; } }
|
2010-06-23 21:03:09 -07:00
|
|
|
|
2011-04-19 13:35:49 -07:00
|
|
|
fn do_work(chan[int] c) {
|
2011-06-15 11:19:50 -07:00
|
|
|
log "in child task";
|
|
|
|
{ let worker w = worker(c); log "constructed worker"; }
|
|
|
|
log "destructed worker";
|
|
|
|
while (true) {
|
|
|
|
// Deadlock-condition not handled properly yet, need to avoid
|
|
|
|
// exiting the child early.
|
|
|
|
|
|
|
|
c <| 11;
|
|
|
|
yield;
|
|
|
|
}
|
2010-06-23 21:03:09 -07:00
|
|
|
}
|
|
|
|
|
2011-04-19 13:35:49 -07:00
|
|
|
fn main() {
|
2011-06-15 11:19:50 -07:00
|
|
|
let port[int] p = port();
|
|
|
|
log "spawning worker";
|
|
|
|
auto w = spawn do_work(chan(p));
|
|
|
|
let int i;
|
|
|
|
log "parent waiting for shutdown";
|
|
|
|
p |> i;
|
|
|
|
log "received int";
|
|
|
|
assert (i == 10);
|
|
|
|
log "int is OK, child-dtor ran as expected";
|
2010-06-23 21:03:09 -07:00
|
|
|
}
|