PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/jruderman/rust
Rust | 39 lines | 19 code | 10 blank | 10 comment | 0 complexity | 93ffc1e3ddb6867014ce918c842c4ddc MD5 | raw file
 1// xfail-test
 2// -*- rust -*-
 3
 4use std;
 5import comm;
 6import task;
 7
 8fn f(c: comm::_chan<int>) {
 9    type t = {_0: int, _1: int, _2: int};
10
11    // Allocate a box.
12    let x: @t = @{_0: 1, _1: 2, _2: 3};
13
14    // Signal parent that we've allocated a box.
15    comm::send(c, 1);
16
17
18    loop {
19        // spin waiting for the parent to kill us.
20        debug!{"child waiting to die..."};
21
22        // while waiting to die, the messages we are
23        // sending to the channel are never received
24        // by the parent, therefore this test cases drops
25        // messages on the floor
26        comm::send(c, 1);
27    }
28}
29
30fn main() {
31    let p = comm::mk_port();
32    task::_spawn(bind f(p.mk_chan()));
33    let i: int;
34
35    // synchronize on event from child.
36    i = p.recv();
37
38    debug!{"parent exiting, killing child"};
39}