Skip to content

Commit

Permalink
Merge #881 #882
Browse files Browse the repository at this point in the history
881: Remove deprecated items r=taiki-e a=taiki-e

This removes the following deprecated items:

- crossbeam-epoch:
  - `CompareAndSetError`
  - `CompareAndSetOrdering`
  - `Atomic::compare_and_set`
  - `Atomic::compare_and_set_weak`
- crossbeam-utils:
  - `AtomicCell::compare_and_swap`

882: Remove unused nightly features r=taiki-e a=taiki-e



Co-authored-by: Taiki Endo <[email protected]>
  • Loading branch information
bors[bot] and taiki-e authored Jul 23, 2022
3 parents 0fbc9e2 + d3187be + d303ef1 commit 568f558
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 285 deletions.
7 changes: 0 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ std = [
# This is enabled by default and also enabled if the `std` feature is enabled.
alloc = ["crossbeam-epoch/alloc", "crossbeam-queue/alloc"]

# Enable to use of unstable functionality.
# This is disabled by default and requires recent nightly compiler.
#
# NOTE: This feature is outside of the normal semver guarantees and minor or
# patch versions of crossbeam may make breaking changes to them at any time.
nightly = ["crossbeam-epoch/nightly", "crossbeam-utils/nightly", "crossbeam-queue/nightly"]

[dependencies]
cfg-if = "1"

Expand Down
15 changes: 5 additions & 10 deletions ci/check-features.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@ 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.
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
# * `--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.
cargo hack build --all --feature-powerset --no-dev-deps --exclude benchmarks

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
1 change: 0 additions & 1 deletion ci/san.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ RUSTFLAGS="${RUSTFLAGS:-} -Z sanitizer=address --cfg crossbeam_sanitize" \
cargo run \
--release \
--target x86_64-unknown-linux-gnu \
--features nightly \
--example sanitize \
--manifest-path crossbeam-epoch/Cargo.toml

Expand Down
5 changes: 1 addition & 4 deletions ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ fi

# Otherwise, run tests and checks with the host target.
cargo check --all --bins --examples --tests --exclude benchmarks
cargo test --all --exclude benchmarks -- --test-threads=1
cargo test --all --all-features --exclude benchmarks -- --test-threads=1

if [[ "$RUST_VERSION" == "nightly"* ]]; then
# Some crates have `nightly` feature, so run tests with --all-features.
cargo test --all --all-features --exclude benchmarks -- --test-threads=1

# Benchmarks are only checked on nightly because depending on unstable features.
cargo check --all --benches
cargo check --bins --manifest-path crossbeam-channel/benchmarks/Cargo.toml
Expand Down
9 changes: 0 additions & 9 deletions crossbeam-epoch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ std = ["alloc", "crossbeam-utils/std", "once_cell"]
# NOTE: Disabling both `std` *and* `alloc` features is not supported yet.
alloc = []

# These features are no longer used.
# TODO: remove in the next major version.
# Enable to use of unstable functionality.
# This is disabled by default and requires recent nightly compiler.
#
# NOTE: This feature is outside of the normal semver guarantees and minor or
# patch versions of crossbeam may make breaking changes to them at any time.
nightly = ["crossbeam-utils/nightly"]

# Enable the use of loom for concurrency testing.
#
# NOTE: This feature is outside of the normal semver guarantees and minor or
Expand Down
205 changes: 0 additions & 205 deletions crossbeam-epoch/src/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,6 @@ use crate::primitive::sync::atomic::AtomicPtr;
use crate::primitive::sync::atomic::AtomicUsize;
use crossbeam_utils::atomic::AtomicConsume;

/// Given ordering for the success case in a compare-exchange operation, returns the strongest
/// appropriate ordering for the failure case.
#[inline]
fn strongest_failure_ordering(ord: Ordering) -> Ordering {
use self::Ordering::*;
match ord {
Relaxed | Release => Relaxed,
Acquire | AcqRel => Acquire,
_ => SeqCst,
}
}

/// The error returned on failed compare-and-set operation.
// TODO: remove in the next major version.
#[deprecated(note = "Use `CompareExchangeError` instead")]
pub type CompareAndSetError<'g, T, P> = CompareExchangeError<'g, T, P>;

/// The error returned on failed compare-and-swap operation.
pub struct CompareExchangeError<'g, T: ?Sized + Pointable, P: Pointer<T>> {
/// The value in the atomic pointer at the time of the failed operation.
Expand All @@ -51,59 +34,6 @@ impl<T, P: Pointer<T> + fmt::Debug> fmt::Debug for CompareExchangeError<'_, T, P
}
}

/// Memory orderings for compare-and-set operations.
///
/// A compare-and-set operation can have different memory orderings depending on whether it
/// succeeds or fails. This trait generalizes different ways of specifying memory orderings.
///
/// The two ways of specifying orderings for compare-and-set are:
///
/// 1. Just one `Ordering` for the success case. In case of failure, the strongest appropriate
/// ordering is chosen.
/// 2. A pair of `Ordering`s. The first one is for the success case, while the second one is
/// for the failure case.
// TODO: remove in the next major version.
#[deprecated(
note = "`compare_and_set` and `compare_and_set_weak` that use this trait are deprecated, \
use `compare_exchange` or `compare_exchange_weak instead`"
)]
pub trait CompareAndSetOrdering {
/// The ordering of the operation when it succeeds.
fn success(&self) -> Ordering;

/// The ordering of the operation when it fails.
///
/// The failure ordering can't be `Release` or `AcqRel` and must be equivalent or weaker than
/// the success ordering.
fn failure(&self) -> Ordering;
}

#[allow(deprecated)]
impl CompareAndSetOrdering for Ordering {
#[inline]
fn success(&self) -> Ordering {
*self
}

#[inline]
fn failure(&self) -> Ordering {
strongest_failure_ordering(*self)
}
}

#[allow(deprecated)]
impl CompareAndSetOrdering for (Ordering, Ordering) {
#[inline]
fn success(&self) -> Ordering {
self.0
}

#[inline]
fn failure(&self) -> Ordering {
self.1
}
}

/// Returns a bitmask containing the unused least significant bits of an aligned pointer to `T`.
#[inline]
fn low_bits<T: ?Sized + Pointable>() -> usize {
Expand Down Expand Up @@ -656,141 +586,6 @@ impl<T: ?Sized + Pointable> Atomic<T> {
Err(prev)
}

/// Stores the pointer `new` (either `Shared` or `Owned`) into the atomic pointer if the current
/// value is the same as `current`. The tag is also taken into account, so two pointers to the
/// same object, but with different tags, will not be considered equal.
///
/// The return value is a result indicating whether the new pointer was written. On success the
/// pointer that was written is returned. On failure the actual current value and `new` are
/// returned.
///
/// This method takes a [`CompareAndSetOrdering`] argument which describes the memory
/// ordering of this operation.
///
/// # Migrating to `compare_exchange`
///
/// `compare_and_set` is equivalent to `compare_exchange` with the following mapping for
/// memory orderings:
///
/// Original | Success | Failure
/// -------- | ------- | -------
/// Relaxed | Relaxed | Relaxed
/// Acquire | Acquire | Acquire
/// Release | Release | Relaxed
/// AcqRel | AcqRel | Acquire
/// SeqCst | SeqCst | SeqCst
///
/// # Examples
///
/// ```
/// # #![allow(deprecated)]
/// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared};
/// use std::sync::atomic::Ordering::SeqCst;
///
/// let a = Atomic::new(1234);
///
/// let guard = &epoch::pin();
/// let curr = a.load(SeqCst, guard);
/// let res1 = a.compare_and_set(curr, Shared::null(), SeqCst, guard);
/// let res2 = a.compare_and_set(curr, Owned::new(5678), SeqCst, guard);
/// # unsafe { drop(curr.into_owned()); } // avoid leak
/// ```
// TODO: remove in the next major version.
#[allow(deprecated)]
#[deprecated(note = "Use `compare_exchange` instead")]
pub fn compare_and_set<'g, O, P>(
&self,
current: Shared<'_, T>,
new: P,
ord: O,
guard: &'g Guard,
) -> Result<Shared<'g, T>, CompareAndSetError<'g, T, P>>
where
O: CompareAndSetOrdering,
P: Pointer<T>,
{
self.compare_exchange(current, new, ord.success(), ord.failure(), guard)
}

/// Stores the pointer `new` (either `Shared` or `Owned`) into the atomic pointer if the current
/// value is the same as `current`. The tag is also taken into account, so two pointers to the
/// same object, but with different tags, will not be considered equal.
///
/// Unlike [`compare_and_set`], this method is allowed to spuriously fail even when comparison
/// succeeds, which can result in more efficient code on some platforms. The return value is a
/// result indicating whether the new pointer was written. On success the pointer that was
/// written is returned. On failure the actual current value and `new` are returned.
///
/// This method takes a [`CompareAndSetOrdering`] argument which describes the memory
/// ordering of this operation.
///
/// [`compare_and_set`]: Atomic::compare_and_set
///
/// # Migrating to `compare_exchange_weak`
///
/// `compare_and_set_weak` is equivalent to `compare_exchange_weak` with the following mapping for
/// memory orderings:
///
/// Original | Success | Failure
/// -------- | ------- | -------
/// Relaxed | Relaxed | Relaxed
/// Acquire | Acquire | Acquire
/// Release | Release | Relaxed
/// AcqRel | AcqRel | Acquire
/// SeqCst | SeqCst | SeqCst
///
/// # Examples
///
/// ```
/// # #![allow(deprecated)]
/// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared};
/// use std::sync::atomic::Ordering::SeqCst;
///
/// let a = Atomic::new(1234);
/// let guard = &epoch::pin();
///
/// let mut new = Owned::new(5678);
/// let mut ptr = a.load(SeqCst, guard);
/// # unsafe { drop(a.load(SeqCst, guard).into_owned()); } // avoid leak
/// loop {
/// match a.compare_and_set_weak(ptr, new, SeqCst, guard) {
/// Ok(p) => {
/// ptr = p;
/// break;
/// }
/// Err(err) => {
/// ptr = err.current;
/// new = err.new;
/// }
/// }
/// }
///
/// let mut curr = a.load(SeqCst, guard);
/// loop {
/// match a.compare_and_set_weak(curr, Shared::null(), SeqCst, guard) {
/// Ok(_) => break,
/// Err(err) => curr = err.current,
/// }
/// }
/// # unsafe { drop(curr.into_owned()); } // avoid leak
/// ```
// TODO: remove in the next major version.
#[allow(deprecated)]
#[deprecated(note = "Use `compare_exchange_weak` instead")]
pub fn compare_and_set_weak<'g, O, P>(
&self,
current: Shared<'_, T>,
new: P,
ord: O,
guard: &'g Guard,
) -> Result<Shared<'g, T>, CompareAndSetError<'g, T, P>>
where
O: CompareAndSetOrdering,
P: Pointer<T>,
{
self.compare_exchange_weak(current, new, ord.success(), ord.failure(), guard)
}

/// Bitwise "and" with the current tag.
///
/// Performs a bitwise "and" operation on the current tag and the argument `val`, and sets the
Expand Down
3 changes: 0 additions & 3 deletions crossbeam-epoch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ cfg_if! {
};
pub use self::collector::{Collector, LocalHandle};
pub use self::guard::{unprotected, Guard};

#[allow(deprecated)]
pub use self::atomic::{CompareAndSetError, CompareAndSetOrdering};
}
}

Expand Down
9 changes: 0 additions & 9 deletions crossbeam-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ std = ["alloc", "crossbeam-utils/std"]
# NOTE: Disabling both `std` *and* `alloc` features is not supported yet.
alloc = []

# These features are no longer used.
# TODO: remove in the next major version.
# Enable to use of unstable functionality.
# This is disabled by default and requires recent nightly compiler.
#
# NOTE: This feature is outside of the normal semver guarantees and minor or
# patch versions of crossbeam may make breaking changes to them at any time.
nightly = ["crossbeam-utils/nightly"]

[dependencies]
cfg-if = "1"

Expand Down
9 changes: 0 additions & 9 deletions crossbeam-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ default = ["std"]
# This is enabled by default.
std = ["once_cell"]

# These features are no longer used.
# TODO: remove in the next major version.
# Enable to use of unstable functionality.
# This is disabled by default and requires recent nightly compiler.
#
# NOTE: This feature is outside of the normal semver guarantees and minor or
# patch versions of crossbeam may make breaking changes to them at any time.
nightly = []

[dependencies]
cfg-if = "1"
once_cell = { version = "1", optional = true }
Expand Down
28 changes: 0 additions & 28 deletions crossbeam-utils/src/atomic/atomic_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,34 +221,6 @@ impl<T: Copy> AtomicCell<T> {
}

impl<T: Copy + Eq> AtomicCell<T> {
/// If the current value equals `current`, stores `new` into the atomic cell.
///
/// The return value is always the previous value. If it is equal to `current`, then the value
/// was updated.
///
/// # Examples
///
/// ```
/// # #![allow(deprecated)]
/// use crossbeam_utils::atomic::AtomicCell;
///
/// let a = AtomicCell::new(1);
///
/// assert_eq!(a.compare_and_swap(2, 3), 1);
/// assert_eq!(a.load(), 1);
///
/// assert_eq!(a.compare_and_swap(1, 2), 1);
/// assert_eq!(a.load(), 2);
/// ```
// TODO: remove in the next major version.
#[deprecated(note = "Use `compare_exchange` instead")]
pub fn compare_and_swap(&self, current: T, new: T) -> T {
match self.compare_exchange(current, new) {
Ok(v) => v,
Err(v) => v,
}
}

/// If the current value equals `current`, stores `new` into the atomic cell.
///
/// The return value is a result indicating whether the new value was written and containing
Expand Down

0 comments on commit 568f558

Please sign in to comment.