Skip to content

Commit 700cff5

Browse files
committed
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.
1 parent f3345cb commit 700cff5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/libstd/macros.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,14 @@ macro_rules! try {
152152
/// thread::spawn(move|| { long_running_task(); tx1.send(()).unwrap(); });
153153
/// thread::spawn(move|| { tx2.send(calculate_the_answer()).unwrap(); });
154154
///
155-
/// select! (
155+
/// select! {
156156
/// _ = rx1.recv() => println!("the long running task finished first"),
157157
/// answer = rx2.recv() => {
158158
/// println!("the answer was: {}", answer.unwrap());
159159
/// }
160-
/// )
160+
/// }
161+
/// # drop(rx1.recv());
162+
/// # drop(rx2.recv());
161163
/// ```
162164
///
163165
/// For more information about select, see the `std::sync::mpsc::Select` structure.

0 commit comments

Comments
 (0)