Skip to content

Commit

Permalink
Merge #831 #832
Browse files Browse the repository at this point in the history
831: Add spin loop hints in tests for Miri r=taiki-e a=cbeuw

This is a better way to do #829 

Miri does not have a pre-emptive scheduler, so once the execution falls into a spin loop it'll hang forever: rust-lang/miri#1388

Similar measures (`yield_now()`) are already present in [some other tests](https://github.com/crossbeam-rs/crossbeam/blob/master/crossbeam-queue/tests/array_queue.rs), but it's missing here

832: Fix links to macro rules in docs r=taiki-e a=alygin

The fix provides explicit links to macro rules in docs because they [are not resolved globally anymore](rust-lang/rust#96676).


Co-authored-by: Andy Wang <[email protected]>
Co-authored-by: Andrew Lygin <[email protected]>
  • Loading branch information
3 people authored May 19, 2022
3 parents 6f52bea + ba07864 + 8eff2a4 commit 80224bc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions crossbeam-channel/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ pub fn at(when: Instant) -> Receiver<Instant> {
///
/// Using a `never` channel to optionally add a timeout to [`select!`]:
///
/// [`select!`]: crate::select!
///
/// ```
/// use std::thread;
/// use std::time::Duration;
Expand Down
2 changes: 2 additions & 0 deletions crossbeam-channel/src/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ pub(crate) fn select_deadline<'a>(
/// The [`select!`] macro is a convenience wrapper around `Select`. However, it cannot select over a
/// dynamically created list of channel operations.
///
/// [`select!`]: crate::select!
///
/// Once a list of operations has been built with `Select`, there are two different ways of
/// proceeding:
///
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/src/select_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ macro_rules! crossbeam_channel_internal {
/// An operation is considered to be ready if it doesn't have to block. Note that it is ready even
/// when it will simply return an error because the channel is disconnected.
///
/// The `select` macro is a convenience wrapper around [`Select`]. However, it cannot select over a
/// The `select!` macro is a convenience wrapper around [`Select`]. However, it cannot select over a
/// dynamically created list of channel operations.
///
/// [`Select`]: super::Select
Expand Down
4 changes: 4 additions & 0 deletions crossbeam-deque/tests/injector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ fn spsc() {
assert_eq!(i, v);
break;
}
#[cfg(miri)]
std::hint::spin_loop();
}
}

Expand Down Expand Up @@ -102,6 +104,8 @@ fn mpmc() {
v[n].fetch_add(1, SeqCst);
break;
}
#[cfg(miri)]
std::hint::spin_loop();
}
}
});
Expand Down
2 changes: 2 additions & 0 deletions crossbeam-deque/tests/lifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ fn spsc() {
assert_eq!(i, v);
break;
}
#[cfg(miri)]
std::hint::spin_loop();
}
}

Expand Down

0 comments on commit 80224bc

Please sign in to comment.