Skip to content

Commit

Permalink
fix(blocking::mpsc): increase durations in doctests (#78)
Browse files Browse the repository at this point in the history
This makes the doctests less likely to fail spuriously.
  • Loading branch information
utkarshgupta137 authored Apr 26, 2023
1 parent b57ce88 commit 465fd3c
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/mpsc/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,23 +596,23 @@ feature! {
/// let (tx, rx) = CHANNEL.split();
///
/// thread::spawn(move || {
/// thread::sleep(Duration::from_millis(150));
/// thread::sleep(Duration::from_millis(600));
/// let mut value = tx.send_ref().unwrap();
/// write!(value, "hello world!")
/// .expect("writing to a `String` should never fail");
/// });
///
/// assert_eq!(
/// Err(&RecvTimeoutError::Timeout),
/// rx.recv_ref_timeout(Duration::from_millis(100)).as_deref().map(String::as_str)
/// rx.recv_ref_timeout(Duration::from_millis(400)).as_deref().map(String::as_str)
/// );
/// assert_eq!(
/// Ok("hello world!"),
/// rx.recv_ref_timeout(Duration::from_millis(100)).as_deref().map(String::as_str)
/// rx.recv_ref_timeout(Duration::from_millis(400)).as_deref().map(String::as_str)
/// );
/// assert_eq!(
/// Err(&RecvTimeoutError::Closed),
/// rx.recv_ref_timeout(Duration::from_millis(100)).as_deref().map(String::as_str)
/// rx.recv_ref_timeout(Duration::from_millis(400)).as_deref().map(String::as_str)
/// );
/// ```
#[cfg(not(all(test, loom)))]
Expand Down Expand Up @@ -653,21 +653,21 @@ feature! {
/// let (tx, rx) = CHANNEL.split();
///
/// thread::spawn(move || {
/// thread::sleep(Duration::from_millis(150));
/// thread::sleep(Duration::from_millis(600));
/// tx.send(1).unwrap();
/// });
///
/// assert_eq!(
/// Err(RecvTimeoutError::Timeout),
/// rx.recv_timeout(Duration::from_millis(100))
/// rx.recv_timeout(Duration::from_millis(400))
/// );
/// assert_eq!(
/// Ok(1),
/// rx.recv_timeout(Duration::from_millis(100))
/// rx.recv_timeout(Duration::from_millis(400))
/// );
/// assert_eq!(
/// Err(RecvTimeoutError::Closed),
/// rx.recv_timeout(Duration::from_millis(100))
/// rx.recv_timeout(Duration::from_millis(400))
/// );
/// ```
#[cfg(not(all(test, loom)))]
Expand Down Expand Up @@ -1158,23 +1158,23 @@ impl<T, R> Receiver<T, R> {
/// let (tx, rx) = blocking::channel::<String>(100);
///
/// thread::spawn(move || {
/// thread::sleep(Duration::from_millis(150));
/// thread::sleep(Duration::from_millis(600));
/// let mut value = tx.send_ref().unwrap();
/// write!(value, "hello world!")
/// .expect("writing to a `String` should never fail");
/// });
///
/// assert_eq!(
/// Err(&RecvTimeoutError::Timeout),
/// rx.recv_ref_timeout(Duration::from_millis(100)).as_deref().map(String::as_str)
/// rx.recv_ref_timeout(Duration::from_millis(400)).as_deref().map(String::as_str)
/// );
/// assert_eq!(
/// Ok("hello world!"),
/// rx.recv_ref_timeout(Duration::from_millis(100)).as_deref().map(String::as_str)
/// rx.recv_ref_timeout(Duration::from_millis(400)).as_deref().map(String::as_str)
/// );
/// assert_eq!(
/// Err(&RecvTimeoutError::Closed),
/// rx.recv_ref_timeout(Duration::from_millis(100)).as_deref().map(String::as_str)
/// rx.recv_ref_timeout(Duration::from_millis(400)).as_deref().map(String::as_str)
/// );
/// ```
#[cfg(not(all(test, loom)))]
Expand Down Expand Up @@ -1215,21 +1215,21 @@ impl<T, R> Receiver<T, R> {
/// let (tx, rx) = blocking::channel(100);
///
/// thread::spawn(move || {
/// thread::sleep(Duration::from_millis(150));
/// thread::sleep(Duration::from_millis(600));
/// tx.send(1).unwrap();
/// });
///
/// assert_eq!(
/// Err(RecvTimeoutError::Timeout),
/// rx.recv_timeout(Duration::from_millis(100))
/// rx.recv_timeout(Duration::from_millis(400))
/// );
/// assert_eq!(
/// Ok(1),
/// rx.recv_timeout(Duration::from_millis(100))
/// rx.recv_timeout(Duration::from_millis(400))
/// );
/// assert_eq!(
/// Err(RecvTimeoutError::Closed),
/// rx.recv_timeout(Duration::from_millis(100))
/// rx.recv_timeout(Duration::from_millis(400))
/// );
/// ```
#[cfg(not(all(test, loom)))]
Expand Down

0 comments on commit 465fd3c

Please sign in to comment.