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
16 changes: 8 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ matrix:
- rust: 1.28.0
name: "crossbeam on 1.28.0"
script: ./ci/crossbeam.sh
- rust: 1.26.0
name: "crossbeam-channel on 1.26.0"
- rust: 1.28.0
name: "crossbeam-channel on 1.28.0"
script: ./ci/crossbeam-channel.sh
- rust: 1.28.0
name: "crossbeam-deque on 1.28.0"
script: ./ci/crossbeam-deque.sh
- rust: 1.26.0
name: "crossbeam-epoch on 1.26.0"
- rust: 1.28.0
name: "crossbeam-epoch on 1.28.0"
script: ./ci/crossbeam-epoch.sh
- rust: 1.26.0
name: "crossbeam-queue on 1.26.0"
- rust: 1.28.0
name: "crossbeam-queue on 1.28.0"
script: ./ci/crossbeam-queue.sh
- rust: 1.28.0
name: "crossbeam-skiplist on 1.28.0"
script: ./ci/crossbeam-skiplist.sh
- rust: 1.26.0
name: "crossbeam-utils on 1.26.0"
- rust: 1.28.0
name: "crossbeam-utils on 1.28.0"
script: ./ci/crossbeam-utils.sh

# Test crates on nightly Rust.
Expand Down
2 changes: 1 addition & 1 deletion 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-channel)
https://crates.io/crates/crossbeam-channel)
[![Documentation](https://docs.rs/crossbeam-channel/badge.svg)](
https://docs.rs/crossbeam-channel)
[![Rust 1.26+](https://img.shields.io/badge/rust-1.26+-lightgray.svg)](
[![Rust 1.28+](https://img.shields.io/badge/rust-1.28+-lightgray.svg)](
https://www.rust-lang.org)
[![chat](https://img.shields.io/discord/569610676205781012.svg?logo=discord)](https://discord.gg/BBYwKq)

Expand Down
2 changes: 1 addition & 1 deletion crossbeam-epoch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ https://github.com/crossbeam-rs/crossbeam-epoch)
https://crates.io/crates/crossbeam-epoch)
[![Documentation](https://docs.rs/crossbeam-epoch/badge.svg)](
https://docs.rs/crossbeam-epoch)
[![Rust 1.26+](https://img.shields.io/badge/rust-1.26+-lightgray.svg)](
[![Rust 1.28+](https://img.shields.io/badge/rust-1.28+-lightgray.svg)](
https://www.rust-lang.org)
[![chat](https://img.shields.io/discord/569610676205781012.svg?logo=discord)](https://discord.gg/BBYwKq)

Expand Down
4 changes: 2 additions & 2 deletions crossbeam-queue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ https://github.com/crossbeam-rs/crossbeam-queue/tree/master/src)
https://crates.io/crates/crossbeam-queue)
[![Documentation](https://docs.rs/crossbeam-queue/badge.svg)](
https://docs.rs/crossbeam-queue)
[![Rust 1.26+](https://img.shields.io/badge/rust-1.26+-lightgray.svg)](
[![Rust 1.28+](https://img.shields.io/badge/rust-1.28+-lightgray.svg)](
https://www.rust-lang.org)
[![chat](https://img.shields.io/discord/569610676205781012.svg?logo=discord)](https://discord.gg/BBYwKq)

Expand Down Expand Up @@ -37,7 +37,7 @@ extern crate crossbeam_queue;

## Compatibility

The minimum supported Rust version is 1.26.
The minimum supported Rust version is 1.28.

## License

Expand Down
2 changes: 1 addition & 1 deletion crossbeam-utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ https://github.com/crossbeam-rs/crossbeam-utils/tree/master/src)
https://crates.io/crates/crossbeam-utils)
[![Documentation](https://docs.rs/crossbeam-utils/badge.svg)](
https://docs.rs/crossbeam-utils)
[![Rust 1.26+](https://img.shields.io/badge/rust-1.26+-lightgray.svg)](
[![Rust 1.28+](https://img.shields.io/badge/rust-1.28+-lightgray.svg)](
https://www.rust-lang.org)
[![chat](https://img.shields.io/discord/569610676205781012.svg?logo=discord)](https://discord.gg/BBYwKq)

Expand Down
76 changes: 57 additions & 19 deletions crossbeam-utils/src/atomic/atomic_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ use Backoff;
/// [`AtomicCell::<T>::is_lock_free()`]: struct.AtomicCell.html#method.is_lock_free
/// [`Acquire`]: https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html#variant.Acquire
/// [`Release`]: https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html#variant.Release
pub struct AtomicCell<T> {
#[repr(transparent)]
pub struct AtomicCell<T: ?Sized> {
/// The inner value.
///
/// If this value can be transmuted into a primitive atomic type, it will be treated as such.
Expand Down Expand Up @@ -49,24 +50,6 @@ impl<T> AtomicCell<T> {
}
}

/// Returns a mutable reference to the inner value.
///
/// # Examples
///
/// ```
/// use crossbeam_utils::atomic::AtomicCell;
///
/// let mut a = AtomicCell::new(7);
/// *a.get_mut() += 1;
///
/// assert_eq!(a.load(), 8);
/// ```
#[doc(hidden)]
#[deprecated(note = "this method is unsound and will be removed in the next release")]
pub fn get_mut(&mut self) -> &mut T {
unsafe { &mut *self.value.get() }
}

/// Unwraps the atomic cell and returns its inner value.
///
/// # Examples
Expand Down Expand Up @@ -156,6 +139,61 @@ impl<T> AtomicCell<T> {
}
}

impl<T: ?Sized> AtomicCell<T> {
/// Returns a raw pointer to the underlying data in this atomic cell.
///
/// # Examples
///
/// ```
/// use crossbeam_utils::atomic::AtomicCell;
///
/// let mut a = AtomicCell::new(5);
///
/// let ptr = a.as_ptr();
/// ```
#[inline]
pub fn as_ptr(&self) -> *mut T {
self.value.get()
}

/// Returns a mutable reference to the inner value.
///
/// # Examples
///
/// ```
/// use crossbeam_utils::atomic::AtomicCell;
///
/// let mut a = AtomicCell::new(7);
/// *a.get_mut() += 1;
///
/// assert_eq!(a.load(), 8);
/// ```
#[doc(hidden)]
#[deprecated(note = "this method is unsound and will be removed in the next release")]
pub fn get_mut(&mut self) -> &mut T {
unsafe { &mut *self.value.get() }
}
}

impl<T: Default> AtomicCell<T> {
/// Takes the value of the atomic cell, leaving `Default::default()` in its place.
///
/// # Examples
///
/// ```
/// use crossbeam_utils::atomic::AtomicCell;
///
/// let a = AtomicCell::new(5);
/// let five = a.take();
///
/// assert_eq!(five, 5);
/// assert_eq!(a.into_inner(), 0);
/// ```
pub fn take(&self) -> T {
self.swap(Default::default())
}
}

impl<T: Copy> AtomicCell<T> {
/// Loads a value.
///
Expand Down