Skip to content

Commit d3187be

Browse files
committed
Remove deprecated items
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`
1 parent 1ea6c55 commit d3187be

File tree

3 files changed

+0
-236
lines changed

3 files changed

+0
-236
lines changed

crossbeam-epoch/src/atomic.rs

-205
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,6 @@ use crate::guard::Guard;
1313
use crate::primitive::sync::atomic::AtomicUsize;
1414
use crossbeam_utils::atomic::AtomicConsume;
1515

16-
/// Given ordering for the success case in a compare-exchange operation, returns the strongest
17-
/// appropriate ordering for the failure case.
18-
#[inline]
19-
fn strongest_failure_ordering(ord: Ordering) -> Ordering {
20-
use self::Ordering::*;
21-
match ord {
22-
Relaxed | Release => Relaxed,
23-
Acquire | AcqRel => Acquire,
24-
_ => SeqCst,
25-
}
26-
}
27-
28-
/// The error returned on failed compare-and-set operation.
29-
// TODO: remove in the next major version.
30-
#[deprecated(note = "Use `CompareExchangeError` instead")]
31-
pub type CompareAndSetError<'g, T, P> = CompareExchangeError<'g, T, P>;
32-
3316
/// The error returned on failed compare-and-swap operation.
3417
pub struct CompareExchangeError<'g, T: ?Sized + Pointable, P: Pointer<T>> {
3518
/// The value in the atomic pointer at the time of the failed operation.
@@ -48,59 +31,6 @@ impl<T, P: Pointer<T> + fmt::Debug> fmt::Debug for CompareExchangeError<'_, T, P
4831
}
4932
}
5033

51-
/// Memory orderings for compare-and-set operations.
52-
///
53-
/// A compare-and-set operation can have different memory orderings depending on whether it
54-
/// succeeds or fails. This trait generalizes different ways of specifying memory orderings.
55-
///
56-
/// The two ways of specifying orderings for compare-and-set are:
57-
///
58-
/// 1. Just one `Ordering` for the success case. In case of failure, the strongest appropriate
59-
/// ordering is chosen.
60-
/// 2. A pair of `Ordering`s. The first one is for the success case, while the second one is
61-
/// for the failure case.
62-
// TODO: remove in the next major version.
63-
#[deprecated(
64-
note = "`compare_and_set` and `compare_and_set_weak` that use this trait are deprecated, \
65-
use `compare_exchange` or `compare_exchange_weak instead`"
66-
)]
67-
pub trait CompareAndSetOrdering {
68-
/// The ordering of the operation when it succeeds.
69-
fn success(&self) -> Ordering;
70-
71-
/// The ordering of the operation when it fails.
72-
///
73-
/// The failure ordering can't be `Release` or `AcqRel` and must be equivalent or weaker than
74-
/// the success ordering.
75-
fn failure(&self) -> Ordering;
76-
}
77-
78-
#[allow(deprecated)]
79-
impl CompareAndSetOrdering for Ordering {
80-
#[inline]
81-
fn success(&self) -> Ordering {
82-
*self
83-
}
84-
85-
#[inline]
86-
fn failure(&self) -> Ordering {
87-
strongest_failure_ordering(*self)
88-
}
89-
}
90-
91-
#[allow(deprecated)]
92-
impl CompareAndSetOrdering for (Ordering, Ordering) {
93-
#[inline]
94-
fn success(&self) -> Ordering {
95-
self.0
96-
}
97-
98-
#[inline]
99-
fn failure(&self) -> Ordering {
100-
self.1
101-
}
102-
}
103-
10434
/// Returns a bitmask containing the unused least significant bits of an aligned pointer to `T`.
10535
#[inline]
10636
fn low_bits<T: ?Sized + Pointable>() -> usize {
@@ -640,141 +570,6 @@ impl<T: ?Sized + Pointable> Atomic<T> {
640570
Err(prev)
641571
}
642572

643-
/// Stores the pointer `new` (either `Shared` or `Owned`) into the atomic pointer if the current
644-
/// value is the same as `current`. The tag is also taken into account, so two pointers to the
645-
/// same object, but with different tags, will not be considered equal.
646-
///
647-
/// The return value is a result indicating whether the new pointer was written. On success the
648-
/// pointer that was written is returned. On failure the actual current value and `new` are
649-
/// returned.
650-
///
651-
/// This method takes a [`CompareAndSetOrdering`] argument which describes the memory
652-
/// ordering of this operation.
653-
///
654-
/// # Migrating to `compare_exchange`
655-
///
656-
/// `compare_and_set` is equivalent to `compare_exchange` with the following mapping for
657-
/// memory orderings:
658-
///
659-
/// Original | Success | Failure
660-
/// -------- | ------- | -------
661-
/// Relaxed | Relaxed | Relaxed
662-
/// Acquire | Acquire | Acquire
663-
/// Release | Release | Relaxed
664-
/// AcqRel | AcqRel | Acquire
665-
/// SeqCst | SeqCst | SeqCst
666-
///
667-
/// # Examples
668-
///
669-
/// ```
670-
/// # #![allow(deprecated)]
671-
/// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared};
672-
/// use std::sync::atomic::Ordering::SeqCst;
673-
///
674-
/// let a = Atomic::new(1234);
675-
///
676-
/// let guard = &epoch::pin();
677-
/// let curr = a.load(SeqCst, guard);
678-
/// let res1 = a.compare_and_set(curr, Shared::null(), SeqCst, guard);
679-
/// let res2 = a.compare_and_set(curr, Owned::new(5678), SeqCst, guard);
680-
/// # unsafe { drop(curr.into_owned()); } // avoid leak
681-
/// ```
682-
// TODO: remove in the next major version.
683-
#[allow(deprecated)]
684-
#[deprecated(note = "Use `compare_exchange` instead")]
685-
pub fn compare_and_set<'g, O, P>(
686-
&self,
687-
current: Shared<'_, T>,
688-
new: P,
689-
ord: O,
690-
guard: &'g Guard,
691-
) -> Result<Shared<'g, T>, CompareAndSetError<'g, T, P>>
692-
where
693-
O: CompareAndSetOrdering,
694-
P: Pointer<T>,
695-
{
696-
self.compare_exchange(current, new, ord.success(), ord.failure(), guard)
697-
}
698-
699-
/// Stores the pointer `new` (either `Shared` or `Owned`) into the atomic pointer if the current
700-
/// value is the same as `current`. The tag is also taken into account, so two pointers to the
701-
/// same object, but with different tags, will not be considered equal.
702-
///
703-
/// Unlike [`compare_and_set`], this method is allowed to spuriously fail even when comparison
704-
/// succeeds, which can result in more efficient code on some platforms. The return value is a
705-
/// result indicating whether the new pointer was written. On success the pointer that was
706-
/// written is returned. On failure the actual current value and `new` are returned.
707-
///
708-
/// This method takes a [`CompareAndSetOrdering`] argument which describes the memory
709-
/// ordering of this operation.
710-
///
711-
/// [`compare_and_set`]: Atomic::compare_and_set
712-
///
713-
/// # Migrating to `compare_exchange_weak`
714-
///
715-
/// `compare_and_set_weak` is equivalent to `compare_exchange_weak` with the following mapping for
716-
/// memory orderings:
717-
///
718-
/// Original | Success | Failure
719-
/// -------- | ------- | -------
720-
/// Relaxed | Relaxed | Relaxed
721-
/// Acquire | Acquire | Acquire
722-
/// Release | Release | Relaxed
723-
/// AcqRel | AcqRel | Acquire
724-
/// SeqCst | SeqCst | SeqCst
725-
///
726-
/// # Examples
727-
///
728-
/// ```
729-
/// # #![allow(deprecated)]
730-
/// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared};
731-
/// use std::sync::atomic::Ordering::SeqCst;
732-
///
733-
/// let a = Atomic::new(1234);
734-
/// let guard = &epoch::pin();
735-
///
736-
/// let mut new = Owned::new(5678);
737-
/// let mut ptr = a.load(SeqCst, guard);
738-
/// # unsafe { drop(a.load(SeqCst, guard).into_owned()); } // avoid leak
739-
/// loop {
740-
/// match a.compare_and_set_weak(ptr, new, SeqCst, guard) {
741-
/// Ok(p) => {
742-
/// ptr = p;
743-
/// break;
744-
/// }
745-
/// Err(err) => {
746-
/// ptr = err.current;
747-
/// new = err.new;
748-
/// }
749-
/// }
750-
/// }
751-
///
752-
/// let mut curr = a.load(SeqCst, guard);
753-
/// loop {
754-
/// match a.compare_and_set_weak(curr, Shared::null(), SeqCst, guard) {
755-
/// Ok(_) => break,
756-
/// Err(err) => curr = err.current,
757-
/// }
758-
/// }
759-
/// # unsafe { drop(curr.into_owned()); } // avoid leak
760-
/// ```
761-
// TODO: remove in the next major version.
762-
#[allow(deprecated)]
763-
#[deprecated(note = "Use `compare_exchange_weak` instead")]
764-
pub fn compare_and_set_weak<'g, O, P>(
765-
&self,
766-
current: Shared<'_, T>,
767-
new: P,
768-
ord: O,
769-
guard: &'g Guard,
770-
) -> Result<Shared<'g, T>, CompareAndSetError<'g, T, P>>
771-
where
772-
O: CompareAndSetOrdering,
773-
P: Pointer<T>,
774-
{
775-
self.compare_exchange_weak(current, new, ord.success(), ord.failure(), guard)
776-
}
777-
778573
/// Bitwise "and" with the current tag.
779574
///
780575
/// Performs a bitwise "and" operation on the current tag and the argument `val`, and sets the

crossbeam-epoch/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,6 @@ cfg_if! {
155155
};
156156
pub use self::collector::{Collector, LocalHandle};
157157
pub use self::guard::{unprotected, Guard};
158-
159-
#[allow(deprecated)]
160-
pub use self::atomic::{CompareAndSetError, CompareAndSetOrdering};
161158
}
162159
}
163160

crossbeam-utils/src/atomic/atomic_cell.rs

-28
Original file line numberDiff line numberDiff line change
@@ -221,34 +221,6 @@ impl<T: Copy> AtomicCell<T> {
221221
}
222222

223223
impl<T: Copy + Eq> AtomicCell<T> {
224-
/// If the current value equals `current`, stores `new` into the atomic cell.
225-
///
226-
/// The return value is always the previous value. If it is equal to `current`, then the value
227-
/// was updated.
228-
///
229-
/// # Examples
230-
///
231-
/// ```
232-
/// # #![allow(deprecated)]
233-
/// use crossbeam_utils::atomic::AtomicCell;
234-
///
235-
/// let a = AtomicCell::new(1);
236-
///
237-
/// assert_eq!(a.compare_and_swap(2, 3), 1);
238-
/// assert_eq!(a.load(), 1);
239-
///
240-
/// assert_eq!(a.compare_and_swap(1, 2), 1);
241-
/// assert_eq!(a.load(), 2);
242-
/// ```
243-
// TODO: remove in the next major version.
244-
#[deprecated(note = "Use `compare_exchange` instead")]
245-
pub fn compare_and_swap(&self, current: T, new: T) -> T {
246-
match self.compare_exchange(current, new) {
247-
Ok(v) => v,
248-
Err(v) => v,
249-
}
250-
}
251-
252224
/// If the current value equals `current`, stores `new` into the atomic cell.
253225
///
254226
/// The return value is a result indicating whether the new value was written and containing

0 commit comments

Comments
 (0)