Skip to content

Commit 5bb2094

Browse files
committedAug 14, 2018
Auto merge of rust-lang#52936 - felixrabe:patch-1, r=alexcrichton
Document rust-lang#39364 – Panic in mpsc::Receiver::recv_timeout I can still reproduce rust-lang#39364 with the example code at rust-lang#39364 (comment). I'm opening this PR in an attempt to document this bug as a known issue in [libstd/sync/mpsc/mod.rs](https://github.com/rust-lang/rust/blob/master/src/libstd/sync/mpsc/mod.rs). Inputs very much welcome. ([Nightly docs for `recv_timeout`.](https://doc.rust-lang.org/nightly/std/sync/mpsc/struct.Receiver.html?search=#method.recv_timeout))

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
 

‎src/libstd/sync/mpsc/mod.rs

+28
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,34 @@ impl<T> Receiver<T> {
12471247
/// [`SyncSender`]: struct.SyncSender.html
12481248
/// [`Err`]: ../../../std/result/enum.Result.html#variant.Err
12491249
///
1250+
/// # Known Issues
1251+
///
1252+
/// There is currently a known issue (see [`#39364`]) that causes `recv_timeout`
1253+
/// 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+
/// ```
1275+
///
1276+
/// [`#39364`]: https://github.com/rust-lang/rust/issues/39364
1277+
///
12501278
/// # Examples
12511279
///
12521280
/// Successfully receiving value before encountering timeout:

0 commit comments

Comments
 (0)
Please sign in to comment.