/src/test/run-pass/task-killjoin.rs

http://github.com/jruderman/rust · Rust · 36 lines · 13 code · 6 blank · 17 comment · 0 complexity · ce41ea8e7ab614c59602fb129b69fc62 MD5 · raw file

  1. // xfail-win32
  2. // Create a task that is supervised by another task, join the supervised task
  3. // from the supervising task, then fail the supervised task. The supervised
  4. // task will kill the supervising task, waking it up. The supervising task no
  5. // longer needs to be wakened when the supervised task exits.
  6. use std;
  7. import task;
  8. fn supervised() {
  9. // Yield to make sure the supervisor joins before we fail. This is
  10. // currently not needed because the supervisor runs first, but I can
  11. // imagine that changing.
  12. task::yield();
  13. fail;
  14. }
  15. fn supervisor() {
  16. // Unsupervise this task so the process doesn't return a failure status as
  17. // a result of the main task being killed.
  18. let f = supervised;
  19. task::try(supervised);
  20. }
  21. fn main() {
  22. task::spawn_unlinked(supervisor)
  23. }
  24. // Local Variables:
  25. // mode: rust;
  26. // fill-column: 78;
  27. // indent-tabs-mode: nil
  28. // c-basic-offset: 4
  29. // buffer-file-coding-system: utf-8-unix
  30. // End: