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
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ defaults:
run:
shell: bash

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
# Test crates on their minimum Rust versions and nightly Rust.
test:
Expand Down Expand Up @@ -75,13 +79,14 @@ jobs:
fail-fast: false
matrix:
rust:
- '1.61'
- msrv
- nightly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: rustup update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
if: matrix.rust != 'msrv'
- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: Check features
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 0.8.3

- Bump the minimum supported Rust version to 1.61. (#1037)

# Version 0.8.2

- Bump the minimum supported Rust version to 1.38. (#877)
Expand Down
40 changes: 9 additions & 31 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ name = "crossbeam"
# - Update CHANGELOG.md
# - Update README.md
# - Create "crossbeam-X.Y.Z" git tag
version = "0.8.2"
edition = "2018"
version = "0.8.3"
edition = "2021"
rust-version = "1.61"
license = "MIT OR Apache-2.0"
repository = "https://github.com/crossbeam-rs/crossbeam"
Expand Down Expand Up @@ -41,41 +41,19 @@ alloc = ["crossbeam-epoch/alloc", "crossbeam-queue/alloc"]
nightly = ["crossbeam-epoch/nightly", "crossbeam-utils/nightly", "crossbeam-queue/nightly"]

[dependencies]
cfg-if = "1"

[dependencies.crossbeam-channel]
version = "0.5.9"
path = "./crossbeam-channel"
default-features = false
optional = true

[dependencies.crossbeam-deque]
version = "0.8.4"
path = "./crossbeam-deque"
default-features = false
optional = true
crossbeam-channel = { version = "0.5.10", path = "crossbeam-channel", default-features = false, optional = true }
crossbeam-deque = { version = "0.8.4", path = "crossbeam-deque", default-features = false, optional = true }
crossbeam-epoch = { version = "0.9.17", path = "crossbeam-epoch", default-features = false, optional = true }
crossbeam-queue = { version = "0.3.10", path = "crossbeam-queue", default-features = false, optional = true }
crossbeam-utils = { version = "0.8.18", path = "crossbeam-utils", default-features = false }

[dependencies.crossbeam-epoch]
version = "0.9.16"
path = "./crossbeam-epoch"
default-features = false
optional = true

[dependencies.crossbeam-queue]
version = "0.3.9"
path = "./crossbeam-queue"
default-features = false
optional = true

[dependencies.crossbeam-utils]
version = "0.8.17"
path = "./crossbeam-utils"
default-features = false
cfg-if = "1"

[dev-dependencies]
rand = "0.8"

[workspace]
resolver = "2"
members = [
".",
"crossbeam-channel",
Expand Down
15 changes: 9 additions & 6 deletions ci/check-features.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ set -euxo pipefail
IFS=$'\n\t'
cd "$(dirname "$0")"/..

if [[ "$RUST_VERSION" != "nightly"* ]]; then
# On MSRV, features other than nightly should work.
# * `--feature-powerset` - run for the feature powerset which includes --no-default-features and default features of package
# * `--no-dev-deps` - build without dev-dependencies to avoid https://github.com/rust-lang/cargo/issues/4866
# * `--exclude benchmarks` - benchmarks doesn't published.
# * `--skip nightly` - skip `nightly` feature as requires nightly compilers.
# * `--feature-powerset` - run for the feature powerset which includes --no-default-features and default features of package
# * `--no-dev-deps` - build without dev-dependencies to avoid https://github.com/rust-lang/cargo/issues/4866
# * `--exclude benchmarks` - benchmarks doesn't published.
# * `--skip nightly` - skip `nightly` feature as requires nightly compilers.
if [[ "${RUST_VERSION}" == "msrv" ]]; then
cargo hack build --all --feature-powerset --no-dev-deps --exclude benchmarks --skip nightly --rust-version
elif [[ "$RUST_VERSION" != "nightly"* ]]; then
cargo hack build --all --feature-powerset --no-dev-deps --exclude benchmarks --skip nightly
else
# On nightly, all feature combinations should work.
cargo hack build --all --feature-powerset --no-dev-deps --exclude benchmarks
fi

if [[ "${RUST_VERSION}" == "nightly"* ]]; then
# Build for no_std environment.
# thumbv7m-none-eabi supports atomic CAS.
# thumbv6m-none-eabi supports atomic, but not atomic CAS.
Expand Down
5 changes: 5 additions & 0 deletions crossbeam-channel/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Version 0.5.10

- Relax the minimum supported Rust version to 1.60. (#1056)
- Optimize `Drop` implementation of bounded channel. (#1057)

# Version 0.5.9

- Bump the minimum supported Rust version to 1.61. (#1037)
Expand Down
14 changes: 5 additions & 9 deletions crossbeam-channel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ name = "crossbeam-channel"
# - Update CHANGELOG.md
# - Update README.md
# - Create "crossbeam-channel-X.Y.Z" git tag
version = "0.5.9"
edition = "2018"
rust-version = "1.61"
version = "0.5.10"
edition = "2021"
rust-version = "1.60"
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 All @@ -24,13 +24,9 @@ default = ["std"]
std = ["crossbeam-utils/std"]

[dependencies]
cfg-if = "1"
crossbeam-utils = { version = "0.8.18", path = "../crossbeam-utils", default-features = false }

[dependencies.crossbeam-utils]
version = "0.8.17"
path = "../crossbeam-utils"
default-features = false
optional = true
cfg-if = "1"

[dev-dependencies]
num_cpus = "1.13.0"
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.61+](https://img.shields.io/badge/rust-1.61+-lightgray.svg)](
[![Rust 1.60+](https://img.shields.io/badge/rust-1.60+-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.61.
version is released. Currently, the minimum supported Rust version is 1.60.

## License

Expand Down
4 changes: 2 additions & 2 deletions crossbeam-channel/benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "benchmarks"
version = "0.1.0"
edition = "2018"
version = "0.0.0"
edition = "2021"
publish = false

[dependencies]
Expand Down
59 changes: 30 additions & 29 deletions crossbeam-channel/src/flavors/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! - <https://docs.google.com/document/d/1yIAYmbvL3JxOKOjuCyon7JhW4cSv1wy5hC0ApeGMV9s/pub>

use std::cell::UnsafeCell;
use std::mem::MaybeUninit;
use std::mem::{self, MaybeUninit};
use std::ptr;
use std::sync::atomic::{self, AtomicUsize, Ordering};
use std::time::Instant;
Expand Down Expand Up @@ -520,37 +520,38 @@ impl<T> Channel<T> {

impl<T> Drop for Channel<T> {
fn drop(&mut self) {
// Get the index of the head.
let head = *self.head.get_mut();
let tail = *self.tail.get_mut();

let hix = head & (self.mark_bit - 1);
let tix = tail & (self.mark_bit - 1);

let len = if hix < tix {
tix - hix
} else if hix > tix {
self.cap - hix + tix
} else if (tail & !self.mark_bit) == head {
0
} else {
self.cap
};

// Loop over all slots that hold a message and drop them.
for i in 0..len {
// Compute the index of the next slot holding a message.
let index = if hix + i < self.cap {
hix + i
if mem::needs_drop::<T>() {
// Get the index of the head.
let head = *self.head.get_mut();
let tail = *self.tail.get_mut();

let hix = head & (self.mark_bit - 1);
let tix = tail & (self.mark_bit - 1);

let len = if hix < tix {
tix - hix
} else if hix > tix {
self.cap - hix + tix
} else if (tail & !self.mark_bit) == head {
0
} else {
hix + i - self.cap
self.cap
};

unsafe {
debug_assert!(index < self.buffer.len());
let slot = self.buffer.get_unchecked_mut(index);
let msg = &mut *slot.msg.get();
msg.as_mut_ptr().drop_in_place();
// Loop over all slots that hold a message and drop them.
for i in 0..len {
// Compute the index of the next slot holding a message.
let index = if hix + i < self.cap {
hix + i
} else {
hix + i - self.cap
};

unsafe {
debug_assert!(index < self.buffer.len());
let slot = self.buffer.get_unchecked_mut(index);
(*slot.msg.get()).assume_init_drop();
}
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions crossbeam-channel/src/flavors/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,8 +604,7 @@ impl<T> Channel<T> {
// Drop the message in the slot.
let slot = (*block).slots.get_unchecked(offset);
slot.wait_write();
let p = &mut *slot.msg.get();
p.as_mut_ptr().drop_in_place();
(*slot.msg.get()).assume_init_drop();
} else {
(*block).wait_next();
// Deallocate the block and move to the next one.
Expand Down Expand Up @@ -663,8 +662,7 @@ impl<T> Drop for Channel<T> {
if offset < BLOCK_CAP {
// Drop the message in the slot.
let slot = (*block).slots.get_unchecked(offset);
let p = &mut *slot.msg.get();
p.as_mut_ptr().drop_in_place();
(*slot.msg.get()).assume_init_drop();
} else {
// Deallocate the block and move to the next one.
let next = *(*block).next.get_mut();
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 @@ -685,7 +685,7 @@ macro_rules! crossbeam_channel_internal {
$default:tt
) => {{
const _LEN: usize = $crate::crossbeam_channel_internal!(@count ($($cases)*));
let _handle: &$crate::internal::SelectHandle = &$crate::never::<()>();
let _handle: &dyn $crate::internal::SelectHandle = &$crate::never::<()>();

#[allow(unused_mut)]
let mut _sel = [(_handle, 0, ::std::ptr::null()); _LEN];
Expand Down
17 changes: 4 additions & 13 deletions crossbeam-deque/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name = "crossbeam-deque"
# - Update README.md
# - Create "crossbeam-deque-X.Y.Z" git tag
version = "0.8.4"
edition = "2018"
edition = "2021"
rust-version = "1.61"
license = "MIT OR Apache-2.0"
repository = "https://github.com/crossbeam-rs/crossbeam"
Expand All @@ -24,19 +24,10 @@ default = ["std"]
std = ["crossbeam-epoch/std", "crossbeam-utils/std"]

[dependencies]
cfg-if = "1"

[dependencies.crossbeam-epoch]
version = "0.9.16"
path = "../crossbeam-epoch"
default-features = false
optional = true
crossbeam-epoch = { version = "0.9.17", path = "../crossbeam-epoch", default-features = false }
crossbeam-utils = { version = "0.8.18", path = "../crossbeam-utils", default-features = false }

[dependencies.crossbeam-utils]
version = "0.8.17"
path = "../crossbeam-utils"
default-features = false
optional = true
cfg-if = "1"

[dev-dependencies]
rand = "0.8"
4 changes: 1 addition & 3 deletions crossbeam-deque/src/deque.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::cell::{Cell, UnsafeCell};
use std::cmp;
use std::fmt;
use std::iter::FromIterator;
use std::marker::PhantomData;
use std::mem::{self, ManuallyDrop, MaybeUninit};
use std::ptr;
Expand Down Expand Up @@ -1987,8 +1986,7 @@ impl<T> Drop for Injector<T> {
if offset < BLOCK_CAP {
// Drop the task in the slot.
let slot = (*block).slots.get_unchecked(offset);
let p = &mut *slot.task.get();
p.as_mut_ptr().drop_in_place();
(*slot.task.get()).assume_init_drop();
} else {
// Deallocate the block and move to the next one.
let next = *(*block).next.get_mut();
Expand Down
4 changes: 4 additions & 0 deletions crossbeam-epoch/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 0.9.17

- Remove dependency on `memoffset`. (#1058)

# Version 0.9.16

- Bump the minimum supported Rust version to 1.61. (#1037)
Expand Down
12 changes: 4 additions & 8 deletions crossbeam-epoch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ name = "crossbeam-epoch"
# - Update CHANGELOG.md
# - Update README.md
# - Create "crossbeam-epoch-X.Y.Z" git tag
version = "0.9.16"
edition = "2018"
version = "0.9.17"
edition = "2021"
rust-version = "1.61"
license = "MIT OR Apache-2.0"
repository = "https://github.com/crossbeam-rs/crossbeam"
Expand Down Expand Up @@ -46,8 +46,9 @@ loom = ["loom-crate", "crossbeam-utils/loom"]
autocfg = "1"

[dependencies]
crossbeam-utils = { version = "0.8.18", path = "../crossbeam-utils", default-features = false }

cfg-if = "1"
memoffset = "0.9"

# Enable the use of loom for concurrency testing.
#
Expand All @@ -56,10 +57,5 @@ memoffset = "0.9"
[target.'cfg(crossbeam_loom)'.dependencies]
loom-crate = { package = "loom", version = "0.7.1", optional = true }

[dependencies.crossbeam-utils]
version = "0.8.17"
path = "../crossbeam-utils"
default-features = false

[dev-dependencies]
rand = "0.8"
Loading