Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ jobs:
matrix:
# aarch64/x86_64 macOS and aarch64 Linux are tested on Cirrus CI
include:
- rust: '1.38'
- rust: '1.61'
os: ubuntu-latest
- rust: '1.38'
- rust: '1.61'
os: windows-latest
- rust: stable
os: ubuntu-latest
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
fail-fast: false
matrix:
rust:
- '1.38'
- '1.61'
- nightly
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name = "crossbeam"
# - Create "crossbeam-X.Y.Z" git tag
version = "0.8.2"
edition = "2018"
rust-version = "1.38"
rust-version = "1.61"
license = "MIT OR Apache-2.0"
repository = "https://github.com/crossbeam-rs/crossbeam"
homepage = "https://github.com/crossbeam-rs/crossbeam"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ https://github.com/crossbeam-rs/crossbeam#license)
https://crates.io/crates/crossbeam)
[![Documentation](https://docs.rs/crossbeam/badge.svg)](
https://docs.rs/crossbeam)
[![Rust 1.38+](https://img.shields.io/badge/rust-1.38+-lightgray.svg)](
[![Rust 1.61+](https://img.shields.io/badge/rust-1.61+-lightgray.svg)](
https://www.rust-lang.org)
[![chat](https://img.shields.io/discord/569610676205781012.svg?logo=discord)](https://discord.com/invite/JXYwgWZ)

Expand Down Expand Up @@ -94,7 +94,7 @@ crossbeam = "0.8"

Crossbeam supports stable Rust releases going back at least six months,
and every time the minimum supported Rust version is increased, a new minor
version is released. Currently, the minimum supported Rust version is 1.38.
version is released. Currently, the minimum supported Rust version is 1.61.

## Contributing

Expand Down
6 changes: 4 additions & 2 deletions ci/miri.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ export RUSTFLAGS="${RUSTFLAGS:-} -Z randomize-layout"
export RUSTDOCFLAGS="${RUSTDOCFLAGS:-} -Z randomize-layout"

MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-symbolic-alignment-check -Zmiri-disable-isolation" \
MIRI_LEAK_CHECK='1' \
cargo miri test \
-p crossbeam-channel \
-p crossbeam-queue \
-p crossbeam-utils 2>&1 | ts -i '%.s '

# -Zmiri-ignore-leaks is needed because we use detached threads in tests/docs: https://github.com/rust-lang/miri/issues/1371
# -Zmiri-ignore-leaks is needed because we use detached threads in tests in tests/golang.rs: https://github.com/rust-lang/miri/issues/1371
MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-symbolic-alignment-check -Zmiri-disable-isolation -Zmiri-ignore-leaks" \
cargo miri test \
-p crossbeam-channel 2>&1 | ts -i '%.s '
-p crossbeam-channel --test golang 2>&1 | ts -i '%.s '

# Use Tree Borrows instead of Stacked Borrows because epoch is not compatible with Stacked Borrows: https://github.com/crossbeam-rs/crossbeam/issues/545#issuecomment-1192785003
MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-symbolic-alignment-check -Zmiri-disable-isolation -Zmiri-tree-borrows" \
Expand Down
36 changes: 8 additions & 28 deletions ci/no_atomic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,26 @@ cd "$(dirname "$0")"/..

file="no_atomic.rs"

no_atomic_cas=()
no_atomic_64=()
no_atomic=()
for target in $(rustc --print target-list); do
target_spec=$(rustc --print target-spec-json -Z unstable-options --target "${target}")
for target_spec in $(rustc -Z unstable-options --print all-target-specs-json | jq -c '. | to_entries | .[]'); do
target=$(jq <<<"${target_spec}" -r '.key')
target_spec=$(jq <<<"${target_spec}" -c '.value')
res=$(jq <<<"${target_spec}" -r 'select(."atomic-cas" == false)')
[[ -z "${res}" ]] || no_atomic_cas+=("${target}")
max_atomic_width=$(jq <<<"${target_spec}" -r '."max-atomic-width"')
min_atomic_width=$(jq <<<"${target_spec}" -r '."min-atomic-width"')
case "${max_atomic_width}" in
# `"max-atomic-width" == 0` means that atomic is not supported at all.
# We do not have a cfg for targets with {8,16}-bit atomic only, so
# for now we treat them the same as targets that do not support atomic.
0) no_atomic+=("${target}") ;;
# It is not clear exactly what `"max-atomic-width" == null` means, but they
# actually seem to have the same max-atomic-width as the target-pointer-width.
# The targets currently included in this group are "mipsel-sony-psp",
# "thumbv4t-none-eabi", "thumbv6m-none-eabi", all of which are
# `"target-pointer-width" == "32"`, so assuming them `"max-atomic-width" == 32`
# for now.
32 | null) no_atomic_64+=("${target}") ;;
# `"max-atomic-width" == 0` means that atomic is not supported at all.
# We do not have a cfg for targets with {8,16}-bit atomic only, so
# for now we treat them the same as targets that do not support atomic.
0 | 8 | 16) no_atomic+=("${target}") ;;
64 | 128) ;;
null | 8 | 16 | 32 | 64 | 128) ;;
*) exit 1 ;;
esac
case "${min_atomic_width}" in
Expand All @@ -44,24 +42,6 @@ cat >"${file}" <<EOF
// This file is @generated by $(basename "$0").
// It is not intended for manual editing.

const NO_ATOMIC_CAS: &[&str] = &[
EOF
for target in "${no_atomic_cas[@]}"; do
echo " \"${target}\"," >>"${file}"
done
cat >>"${file}" <<EOF
];

#[allow(dead_code)] // Only crossbeam-utils uses this.
const NO_ATOMIC_64: &[&str] = &[
EOF
for target in "${no_atomic_64[@]}"; do
echo " \"${target}\"," >>"${file}"
done
cat >>"${file}" <<EOF
];

#[allow(dead_code)] // Only crossbeam-utils uses this.
const NO_ATOMIC: &[&str] = &[
EOF
for target in "${no_atomic[@]}"; do
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name = "crossbeam-channel"
# - Create "crossbeam-channel-X.Y.Z" git tag
version = "0.5.8"
edition = "2018"
rust-version = "1.38"
rust-version = "1.61"
license = "MIT OR Apache-2.0"
repository = "https://github.com/crossbeam-rs/crossbeam"
homepage = "https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-channel"
Expand Down
4 changes: 2 additions & 2 deletions crossbeam-channel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-channel#license)
https://crates.io/crates/crossbeam-channel)
[![Documentation](https://docs.rs/crossbeam-channel/badge.svg)](
https://docs.rs/crossbeam-channel)
[![Rust 1.38+](https://img.shields.io/badge/rust-1.38+-lightgray.svg)](
[![Rust 1.61+](https://img.shields.io/badge/rust-1.61+-lightgray.svg)](
https://www.rust-lang.org)
[![chat](https://img.shields.io/discord/569610676205781012.svg?logo=discord)](https://discord.com/invite/JXYwgWZ)

Expand Down Expand Up @@ -48,7 +48,7 @@ crossbeam-channel = "0.5"

Crossbeam Channel supports stable Rust releases going back at least six months,
and every time the minimum supported Rust version is increased, a new minor
version is released. Currently, the minimum supported Rust version is 1.38.
version is released. Currently, the minimum supported Rust version is 1.61.

## License

Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/examples/stopwatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {
// Creates a channel that gets a message every time `SIGINT` is signalled.
fn sigint_notifier() -> io::Result<Receiver<()>> {
let (s, r) = bounded(100);
let mut signals = Signals::new(&[SIGINT])?;
let mut signals = Signals::new([SIGINT])?;

thread::spawn(move || {
for _ in signals.forever() {
Expand Down
6 changes: 6 additions & 0 deletions crossbeam-channel/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ pub fn at(when: Instant) -> Receiver<Instant> {
///
/// let (s, r) = unbounded();
///
/// # let t =
/// thread::spawn(move || {
/// thread::sleep(Duration::from_secs(1));
/// s.send(1).unwrap();
Expand All @@ -265,6 +266,7 @@ pub fn at(when: Instant) -> Receiver<Instant> {
/// recv(r) -> msg => assert_eq!(msg, Ok(1)),
/// recv(timeout) -> _ => println!("timed out"),
/// }
/// # t.join().unwrap(); // join thread to avoid https://github.com/rust-lang/miri/issues/1371
/// ```
pub fn never<T>() -> Receiver<T> {
Receiver {
Expand Down Expand Up @@ -1103,6 +1105,7 @@ impl<T> Receiver<T> {
///
/// let (s, r) = unbounded::<i32>();
///
/// # let t =
/// thread::spawn(move || {
/// s.send(1).unwrap();
/// thread::sleep(Duration::from_secs(1));
Expand All @@ -1118,6 +1121,7 @@ impl<T> Receiver<T> {
/// let v: Vec<_> = r.try_iter().collect();
///
/// assert_eq!(v, [1, 2]);
/// # t.join().unwrap(); // join thread to avoid https://github.com/rust-lang/miri/issues/1371
/// ```
pub fn try_iter(&self) -> TryIter<'_, T> {
TryIter { receiver: self }
Expand Down Expand Up @@ -1269,6 +1273,7 @@ impl<T> fmt::Debug for Iter<'_, T> {
///
/// let (s, r) = unbounded::<i32>();
///
/// # let t =
/// thread::spawn(move || {
/// s.send(1).unwrap();
/// thread::sleep(Duration::from_secs(1));
Expand All @@ -1284,6 +1289,7 @@ impl<T> fmt::Debug for Iter<'_, T> {
/// let v: Vec<_> = r.try_iter().collect();
///
/// assert_eq!(v, [1, 2]);
/// # t.join().unwrap(); // join thread to avoid https://github.com/rust-lang/miri/issues/1371
/// ```
pub struct TryIter<'a, T> {
receiver: &'a Receiver<T>,
Expand Down
40 changes: 8 additions & 32 deletions crossbeam-channel/src/err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,12 @@ impl<T> TrySendError<T> {

/// Returns `true` if the send operation failed because the channel is full.
pub fn is_full(&self) -> bool {
match self {
TrySendError::Full(_) => true,
_ => false,
}
matches!(self, TrySendError::Full(_))
}

/// Returns `true` if the send operation failed because the channel is disconnected.
pub fn is_disconnected(&self) -> bool {
match self {
TrySendError::Disconnected(_) => true,
_ => false,
}
matches!(self, TrySendError::Disconnected(_))
}
}

Expand Down Expand Up @@ -264,18 +258,12 @@ impl<T> SendTimeoutError<T> {

/// Returns `true` if the send operation timed out.
pub fn is_timeout(&self) -> bool {
match self {
SendTimeoutError::Timeout(_) => true,
_ => false,
}
matches!(self, SendTimeoutError::Timeout(_))
}

/// Returns `true` if the send operation failed because the channel is disconnected.
pub fn is_disconnected(&self) -> bool {
match self {
SendTimeoutError::Disconnected(_) => true,
_ => false,
}
matches!(self, SendTimeoutError::Disconnected(_))
}
}

Expand Down Expand Up @@ -309,18 +297,12 @@ impl From<RecvError> for TryRecvError {
impl TryRecvError {
/// Returns `true` if the receive operation failed because the channel is empty.
pub fn is_empty(&self) -> bool {
match self {
TryRecvError::Empty => true,
_ => false,
}
matches!(self, TryRecvError::Empty)
}

/// Returns `true` if the receive operation failed because the channel is disconnected.
pub fn is_disconnected(&self) -> bool {
match self {
TryRecvError::Disconnected => true,
_ => false,
}
matches!(self, TryRecvError::Disconnected)
}
}

Expand All @@ -346,18 +328,12 @@ impl From<RecvError> for RecvTimeoutError {
impl RecvTimeoutError {
/// Returns `true` if the receive operation timed out.
pub fn is_timeout(&self) -> bool {
match self {
RecvTimeoutError::Timeout => true,
_ => false,
}
matches!(self, RecvTimeoutError::Timeout)
}

/// Returns `true` if the receive operation failed because the channel is disconnected.
pub fn is_disconnected(&self) -> bool {
match self {
RecvTimeoutError::Disconnected => true,
_ => false,
}
matches!(self, RecvTimeoutError::Disconnected)
}
}

Expand Down
4 changes: 4 additions & 0 deletions crossbeam-channel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@
//! let (s1, r1) = unbounded();
//! let (s2, r2) = unbounded();
//!
//! # let t1 =
//! thread::spawn(move || s1.send(10).unwrap());
//! # let t2 =
//! thread::spawn(move || s2.send(20).unwrap());
//!
//! // At most one of these two receive operations will be executed.
Expand All @@ -282,6 +284,8 @@
//! recv(r2) -> msg => assert_eq!(msg, Ok(20)),
//! default(Duration::from_secs(1)) => println!("timed out"),
//! }
//! # t1.join().unwrap(); // join thread to avoid https://github.com/rust-lang/miri/issues/1371
//! # t2.join().unwrap(); // join thread to avoid https://github.com/rust-lang/miri/issues/1371
//! ```
//!
//! If you need to select over a dynamically created list of channel operations, use [`Select`]
Expand Down
Loading