X-Git-Url: https://git.ralfj.de/rust-101.git/blobdiff_plain/562558d25054c5be82f11acad0fbe53699de5b1c..ccf679adb3790903849f7d85b970b67582220952:/src/part12.rs diff --git a/src/part12.rs b/src/part12.rs index 8a14def..dc0da61 100644 --- a/src/part12.rs +++ b/src/part12.rs @@ -1,5 +1,5 @@ -// Rust-101, Part 12: Concurrency, Send -// ==================================== +// Rust-101, Part 12: Concurrency, Arc, Send +// ========================================= use std::io::prelude::*; use std::{io, fs, thread}; @@ -124,6 +124,9 @@ pub fn run(options: Options) { let handle3 = thread::spawn(move || output_lines(options3, filtered_receiver)); // Finally, wait until all three threads did their job. + //@ Joining a thread waits for its termination. This can fail if that thread panicked: In this case, we could get + //@ access to the data that it provided to `panic!`. Here, we just assert that they did not panic - so we will panic ourselves + //@ if that happened. handle1.join().unwrap(); handle2.join().unwrap(); handle3.join().unwrap();