rust/src/test/run-pass/acyclic-unwind.rs

42 lines
858 B
Rust
Raw Normal View History

// xfail-stage1
// xfail-stage2
// xfail-stage3
2010-06-23 23:03:09 -05:00
// -*- rust -*-
use std;
import std::comm;
import std::task;
fn f(c: comm::_chan<int>) {
2011-07-27 07:19:39 -05:00
type t = {_0: int, _1: int, _2: int};
2010-06-23 23:03:09 -05:00
2011-07-27 07:19:39 -05:00
// Allocate a box.
let x: @t = @{_0: 1, _1: 2, _2: 3};
2010-06-23 23:03:09 -05:00
2011-07-27 07:19:39 -05:00
// Signal parent that we've allocated a box.
comm::send(c, 1);
2010-06-23 23:03:09 -05:00
2010-08-16 17:04:33 -05:00
2011-07-27 07:19:39 -05:00
while true {
// spin waiting for the parent to kill us.
log "child waiting to die...";
// while waiting to die, the messages we are
// sending to the channel are never received
// by the parent, therefore this test cases drops
// messages on the floor
comm::send(c, 1);
2011-07-27 07:19:39 -05:00
}
2010-06-23 23:03:09 -05:00
}
2011-04-19 15:35:49 -05:00
fn main() {
let p = comm::mk_port();
task::_spawn(bind f(p.mk_chan()));
2011-07-27 07:19:39 -05:00
let i: int;
2010-06-23 23:03:09 -05:00
2011-07-27 07:19:39 -05:00
// synchronize on event from child.
i = p.recv();
2010-06-23 23:03:09 -05:00
2011-07-27 07:19:39 -05:00
log "parent exiting, killing child";
}