1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // xfail-test linked failure
13 // A port of task-killjoin to use a class with a dtor to manage
22 ch: Chan<bool>, v: @mut bool,
26 impl Drop for notify {
29 error!("notify: task=%? v=%x unwinding=%b b=%b",
31 ptr::to_unsafe_ptr(&(*(self.v))) as uint,
40 fn notify(ch: Chan<bool>, v: @mut bool) -> notify {
47 fn joinable(f: ~fn()) -> Port<bool> {
48 fn wrapper(c: Chan<bool>, f: &fn()) {
50 error!("wrapper: task=%? allocated v=%x",
52 ptr::to_unsafe_ptr(&(*b)) as uint);
53 let _r = notify(c, b);
57 let (p, c) = stream();
59 do task::spawn_unlinked {
66 fn join(port: Port<bool>) -> bool {
71 // Deschedule to make sure the supervisor joins before we
72 // fail. This is currently not needed because the supervisor
73 // runs first, but I can imagine that changing.
74 error!("supervised task=%?", 0);
80 error!("supervisor task=%?", 0);
81 let t = joinable(supervised);
86 join(joinable(supervisor));