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

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