3 ms·
FWIW, linked failure was recently removed from Rust. I believe the current plan is to reintroduce it only on channel boundaries (so failure propagates across ch
by eridius 13y ago
FWIW, linked failure was recently removed from Rust. I believe the current plan is to reintroduce it only on channel boundaries (so failure propagates across channels).
- portmanteaufu 13y agoI read about this in the mailing list, but never having relied on linked failure in the past I wasn't sure what the implications were. Could someone give an example of when this would've been used before and how you might accomplish the same in its absence?
- eridius 13y agoWith linked task failure, this program here would cause the main task to fail, which results in the entire program aborting (once all tasks have finished failing): fn main() { // we can't introduce synchronization for this example, so print repeatedly on the main task and check the output for ordering do spawn { fail!("child task failure"); } for i in range(0u, 50) { println!("print line {}", i); } } Without linked task failure, the spawned task will fail, but the main task will continue on. If you want to reintroduce linked task failure with current master, you can do so explicitly using `std::task::TaskBuilder.future_result()`. It's a bit awkward though. And you can probably do better than what I have here, it's just a quick sample: fn main() { let mut builder = std::task::task(); let future = builder.future_result(); do builder.spawn() { fail!("child task failure"); } // check for failure before each of our prints for i in range(0u, 50) { if future.peek() && future.recv().is_err() { fail!("parent task failing because of child failure"); } println!("print line {}", i); } // and block on the result in the end if future.try_recv().map_default(false, |r| r.is_err()) { fail!("parent task failing because of child failure"); } }