Skip to content

Commit b1f47aa

Browse files
authored
Document panic in mpsc::Receiver::recv_timeout
1 parent c3fdd19 commit b1f47aa

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/libstd/sync/mpsc/mod.rs

+23-1
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,29 @@ impl<T> Receiver<T> {
12491249
///
12501250
/// # Panics
12511251
///
1252-
/// Panics due to a known issue ([`#39364`][]).
1252+
/// There is currently a known issue with this function ([`#39364`]) that
1253+
/// causes `recv_timeout` to panic unexpectedly with the following example:
1254+
///
1255+
/// ```no_run
1256+
/// use std::sync::mpsc::channel;
1257+
/// use std::thread;
1258+
/// use std::time::Duration;
1259+
///
1260+
/// let (tx, rx) = channel::<String>();
1261+
///
1262+
/// thread::spawn(move || {
1263+
/// let d = Duration::from_millis(10);
1264+
/// loop {
1265+
/// println!("recv");
1266+
/// let _r = rx.recv_timeout(d);
1267+
/// }
1268+
/// });
1269+
///
1270+
/// thread::sleep(Duration::from_millis(100));
1271+
/// let _c1 = tx.clone();
1272+
///
1273+
/// thread::sleep(Duration::from_secs(1));
1274+
/// ```
12531275
///
12541276
/// [`#39364`]: https://github.com/rust-lang/rust/issues/39364
12551277
///

0 commit comments

Comments
 (0)