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