PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test/run-pass/task-comm-15.rs

http://github.com/jruderman/rust
Rust | 21 lines | 14 code | 2 blank | 5 comment | 1 complexity | 711f7584f7f2c9668e0951419131301e MD5 | raw file
 1// xfail-win32
 2use std;
 3import task;
 4
 5fn start(c: pipes::chan<int>, i0: int) {
 6    let mut i = i0;
 7    while i > 0 {
 8        c.send(0);
 9        i = i - 1;
10    }
11}
12
13fn main() {
14    // Spawn a task that sends us back messages. The parent task
15    // is likely to terminate before the child completes, so from
16    // the child's point of view the receiver may die. We should
17    // drop messages on the floor in this case, and not crash!
18    let (ch, p) = pipes::stream();
19    task::spawn(|| start(ch, 10));
20    p.recv();
21}