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
19 changes: 10 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:

env:
RUSTFLAGS: -Dwarnings
RUSTDOCFLAGS: -Dwarnings
RUST_BACKTRACE: 1

defaults:
Expand Down Expand Up @@ -69,7 +70,7 @@ jobs:
uses: taiki-e/install-action@cross
if: matrix.target != ''
- name: Test
run: ./ci/test.sh
run: ci/test.sh

# Check all feature combinations works properly.
features:
Expand All @@ -90,7 +91,7 @@ jobs:
- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: Check features
run: ./ci/check-features.sh
run: ci/check-features.sh

# Check for duplicate dependencies.
dependencies:
Expand All @@ -104,7 +105,7 @@ jobs:
- name: Install cargo-minimal-versions
uses: taiki-e/install-action@cargo-minimal-versions
- name: dependency tree check
run: ./ci/dependencies.sh
run: ci/dependencies.sh

# When this job failed, run ci/no_atomic.sh and commit result changes.
codegen:
Expand Down Expand Up @@ -150,7 +151,7 @@ jobs:
- name: Install Rust
run: rustup update stable
- name: rustfmt
run: ./ci/rustfmt.sh
run: cargo fmt --all --check

# This branch no longer actively developed. Most commits to this
# branch are backporting and should not be blocked by clippy.
Expand All @@ -162,7 +163,7 @@ jobs:
# - name: Install Rust
# run: rustup update stable
# - name: clippy
# run: ./ci/clippy.sh
# run: cargo clippy --all --tests --examples

# Run miri.
miri:
Expand All @@ -172,7 +173,7 @@ jobs:
- name: Install Rust
run: rustup toolchain install nightly --component miri && rustup default nightly
- name: miri
run: ./ci/miri.sh
run: ci/miri.sh

# Run sanitizers.
san:
Expand All @@ -182,7 +183,7 @@ jobs:
- name: Install Rust
run: rustup update nightly && rustup default nightly
- name: Run sanitizers
run: ./ci/san.sh
run: ci/san.sh

# Run loom tests.
loom:
Expand All @@ -192,7 +193,7 @@ jobs:
- name: Install Rust
run: rustup update stable
- name: loom
run: ./ci/crossbeam-epoch-loom.sh
run: ci/crossbeam-epoch-loom.sh

# Check if the document can be generated without warning.
docs:
Expand All @@ -202,7 +203,7 @@ jobs:
- name: Install Rust
run: rustup update nightly && rustup default nightly
- name: docs
run: ./ci/docs.sh
run: cargo doc --no-deps --all --all-features

shellcheck:
runs-on: ubuntu-latest
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.4

- Remove dependency on `cfg-if`. (#1072)

# Version 0.8.3

- Bump the minimum supported Rust version to 1.61. (#1037)
Expand Down
4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name = "crossbeam"
# - Update CHANGELOG.md
# - Update README.md
# - Create "crossbeam-X.Y.Z" git tag
version = "0.8.3"
version = "0.8.4"
edition = "2021"
rust-version = "1.61"
license = "MIT OR Apache-2.0"
Expand Down Expand Up @@ -47,8 +47,6 @@ crossbeam-epoch = { version = "0.9.17", path = "crossbeam-epoch", default-featur
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 }

cfg-if = "1"

[dev-dependencies]
rand = "0.8"

Expand Down
8 changes: 0 additions & 8 deletions ci/clippy.sh

This file was deleted.

8 changes: 0 additions & 8 deletions ci/docs.sh

This file was deleted.

8 changes: 0 additions & 8 deletions ci/rustfmt.sh

This file was deleted.

4 changes: 4 additions & 0 deletions crossbeam-channel/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 0.5.11

- Remove dependency on `cfg-if`. (#1072)

# Version 0.5.10

- Relax the minimum supported Rust version to 1.60. (#1056)
Expand Down
4 changes: 1 addition & 3 deletions crossbeam-channel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name = "crossbeam-channel"
# - Update CHANGELOG.md
# - Update README.md
# - Create "crossbeam-channel-X.Y.Z" git tag
version = "0.5.10"
version = "0.5.11"
edition = "2021"
rust-version = "1.60"
license = "MIT OR Apache-2.0"
Expand All @@ -26,8 +26,6 @@ std = ["crossbeam-utils/std"]
[dependencies]
crossbeam-utils = { version = "0.8.18", path = "../crossbeam-utils", default-features = false }

cfg-if = "1"

[dev-dependencies]
num_cpus = "1.13.0"
rand = "0.8"
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/benchmarks/flume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn shuffle<T>(v: &mut [T]) {
}

thread_local! {
static RNG: Cell<Wrapping<u32>> = Cell::new(Wrapping(1));
static RNG: Cell<Wrapping<u32>> = const { Cell::new(Wrapping(1)) };
}

RNG.with(|rng| {
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/benchmarks/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::fmt;
const LEN: usize = 1;

#[derive(Clone, Copy)]
pub struct Message(pub [usize; LEN]);
pub struct Message(#[allow(dead_code)] [usize; LEN]);

impl fmt::Debug for Message {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/benchmarks/mpsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub fn shuffle<T>(v: &mut [T]) {
}

thread_local! {
static RNG: Cell<Wrapping<u32>> = Cell::new(Wrapping(1));
static RNG: Cell<Wrapping<u32>> = const { Cell::new(Wrapping(1)) };
}

RNG.with(|rng| {
Expand Down
66 changes: 35 additions & 31 deletions crossbeam-channel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,36 +336,40 @@
)]
#![cfg_attr(not(feature = "std"), no_std)]

use cfg_if::cfg_if;
#[cfg(feature = "std")]
mod channel;
#[cfg(feature = "std")]
mod context;
#[cfg(feature = "std")]
mod counter;
#[cfg(feature = "std")]
mod err;
#[cfg(feature = "std")]
mod flavors;
#[cfg(feature = "std")]
mod select;
#[cfg(feature = "std")]
mod select_macro;
#[cfg(feature = "std")]
mod utils;
#[cfg(feature = "std")]
mod waker;

cfg_if! {
if #[cfg(feature = "std")] {
mod channel;
mod context;
mod counter;
mod err;
mod flavors;
mod select;
mod select_macro;
mod utils;
mod waker;

/// Crate internals used by the `select!` macro.
#[doc(hidden)]
pub mod internal {
pub use crate::select::SelectHandle;
pub use crate::select::{select, select_timeout, try_select};
}

pub use crate::channel::{after, at, never, tick};
pub use crate::channel::{bounded, unbounded};
pub use crate::channel::{IntoIter, Iter, TryIter};
pub use crate::channel::{Receiver, Sender};

pub use crate::select::{Select, SelectedOperation};

pub use crate::err::{ReadyTimeoutError, SelectTimeoutError, TryReadyError, TrySelectError};
pub use crate::err::{RecvError, RecvTimeoutError, TryRecvError};
pub use crate::err::{SendError, SendTimeoutError, TrySendError};
}
/// Crate internals used by the `select!` macro.
#[doc(hidden)]
#[cfg(feature = "std")]
pub mod internal {
pub use crate::select::{select, select_timeout, try_select, SelectHandle};
}

#[cfg(feature = "std")]
pub use crate::{
channel::{
after, at, bounded, never, tick, unbounded, IntoIter, Iter, Receiver, Sender, TryIter,
},
err::{
ReadyTimeoutError, RecvError, RecvTimeoutError, SelectTimeoutError, SendError,
SendTimeoutError, TryReadyError, TryRecvError, TrySelectError, TrySendError,
},
select::{Select, SelectedOperation},
};
2 changes: 1 addition & 1 deletion crossbeam-channel/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub(crate) fn shuffle<T>(v: &mut [T]) {
}

thread_local! {
static RNG: Cell<Wrapping<u32>> = Cell::new(Wrapping(1_406_868_647));
static RNG: Cell<Wrapping<u32>> = const { Cell::new(Wrapping(1_406_868_647)) };
}

let _ = RNG.try_with(|rng| {
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/tests/thread_locals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn use_while_exiting() {
}

thread_local! {
static FOO: Foo = Foo;
static FOO: Foo = const { Foo };
}

let (s, r) = unbounded::<()>();
Expand Down
4 changes: 4 additions & 0 deletions crossbeam-deque/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 0.8.5

- Remove dependency on `cfg-if`. (#1072)

# Version 0.8.4

- Bump the minimum supported Rust version to 1.61. (#1037)
Expand Down
4 changes: 1 addition & 3 deletions crossbeam-deque/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name = "crossbeam-deque"
# - Update CHANGELOG.md
# - Update README.md
# - Create "crossbeam-deque-X.Y.Z" git tag
version = "0.8.4"
version = "0.8.5"
edition = "2021"
rust-version = "1.61"
license = "MIT OR Apache-2.0"
Expand All @@ -27,7 +27,5 @@ std = ["crossbeam-epoch/std", "crossbeam-utils/std"]
crossbeam-epoch = { version = "0.9.17", path = "../crossbeam-epoch", default-features = false }
crossbeam-utils = { version = "0.8.18", path = "../crossbeam-utils", default-features = false }

cfg-if = "1"

[dev-dependencies]
rand = "0.8"
20 changes: 14 additions & 6 deletions crossbeam-deque/src/deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ use std::cell::{Cell, UnsafeCell};
use std::cmp;
use std::fmt;
use std::marker::PhantomData;
use std::mem::{self, ManuallyDrop, MaybeUninit};
use std::mem::{self, MaybeUninit};
use std::ptr;
use std::slice;
use std::sync::atomic::{self, AtomicIsize, AtomicPtr, AtomicUsize, Ordering};
use std::sync::Arc;

use crate::epoch::{self, Atomic, Owned};
use crate::utils::{Backoff, CachePadded};
use crossbeam_epoch::{self as epoch, Atomic, Owned};
use crossbeam_utils::{Backoff, CachePadded};

// Minimum buffer capacity.
const MIN_CAP: usize = 64;
Expand Down Expand Up @@ -37,15 +38,22 @@ impl<T> Buffer<T> {
fn alloc(cap: usize) -> Buffer<T> {
debug_assert_eq!(cap, cap.next_power_of_two());

let mut v = ManuallyDrop::new(Vec::with_capacity(cap));
let ptr = v.as_mut_ptr();
let ptr = Box::into_raw(
(0..cap)
.map(|_| MaybeUninit::<T>::uninit())
.collect::<Box<[_]>>(),
)
.cast::<T>();

Buffer { ptr, cap }
}

/// Deallocates the buffer.
unsafe fn dealloc(self) {
drop(Vec::from_raw_parts(self.ptr, 0, self.cap));
drop(Box::from_raw(slice::from_raw_parts_mut(
self.ptr.cast::<MaybeUninit<T>>(),
self.cap,
)));
}

/// Returns a pointer to the task at the specified `index`.
Expand Down
15 changes: 4 additions & 11 deletions crossbeam-deque/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,7 @@
)]
#![cfg_attr(not(feature = "std"), no_std)]

use cfg_if::cfg_if;

cfg_if! {
if #[cfg(feature = "std")] {
use crossbeam_epoch as epoch;
use crossbeam_utils as utils;

mod deque;
pub use crate::deque::{Injector, Steal, Stealer, Worker};
}
}
#[cfg(feature = "std")]
mod deque;
#[cfg(feature = "std")]
pub use crate::deque::{Injector, Steal, Stealer, Worker};
5 changes: 5 additions & 0 deletions crossbeam-epoch/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Version 0.9.18

- Remove dependency on `cfg-if`. (#1072)
- Remove dependency on `autocfg`. (#1071)

# Version 0.9.17

- Remove dependency on `memoffset`. (#1058)
Expand Down
Loading