std: Join threads in select! doctest
This test has deadlocked on Windows once or twice now and we've had lots of problems in the past of threads panicking when the process is being shut down. One of the two threads in this test is guaranteed to panic because of the `.unwrap()` on the `send` calls, so just call `recv` on both receivers after the test executes to ensure that both threads are dying/dead.
This commit is contained in:
parent
f3345cb0a7
commit
700cff5262
@ -152,12 +152,14 @@ macro_rules! try {
|
|||||||
/// thread::spawn(move|| { long_running_task(); tx1.send(()).unwrap(); });
|
/// thread::spawn(move|| { long_running_task(); tx1.send(()).unwrap(); });
|
||||||
/// thread::spawn(move|| { tx2.send(calculate_the_answer()).unwrap(); });
|
/// thread::spawn(move|| { tx2.send(calculate_the_answer()).unwrap(); });
|
||||||
///
|
///
|
||||||
/// select! (
|
/// select! {
|
||||||
/// _ = rx1.recv() => println!("the long running task finished first"),
|
/// _ = rx1.recv() => println!("the long running task finished first"),
|
||||||
/// answer = rx2.recv() => {
|
/// answer = rx2.recv() => {
|
||||||
/// println!("the answer was: {}", answer.unwrap());
|
/// println!("the answer was: {}", answer.unwrap());
|
||||||
/// }
|
/// }
|
||||||
/// )
|
/// }
|
||||||
|
/// # drop(rx1.recv());
|
||||||
|
/// # drop(rx2.recv());
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// For more information about select, see the `std::sync::mpsc::Select` structure.
|
/// For more information about select, see the `std::sync::mpsc::Select` structure.
|
||||||
|
Loading…
Reference in New Issue
Block a user