Skip to content

Commit

Permalink
AtomicCell: Use fetch_{min,max}
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Dec 13, 2023
1 parent cf9d974 commit cb896e8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crossbeam-utils/src/atomic/atomic_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,8 @@ macro_rules! impl_arithmetic {
atomic! {
$t, _a,
{
// TODO: Atomic*::fetch_max requires Rust 1.45.
self.fetch_update(|old| Some(cmp::max(old, val))).unwrap()
let a = unsafe { &*(self.as_ptr() as *const atomic::$atomic) };
a.fetch_max(val, Ordering::AcqRel)
},
{
let _guard = lock(self.as_ptr() as usize).write();
Expand Down Expand Up @@ -764,8 +764,8 @@ macro_rules! impl_arithmetic {
atomic! {
$t, _a,
{
// TODO: Atomic*::fetch_min requires Rust 1.45.
self.fetch_update(|old| Some(cmp::min(old, val))).unwrap()
let a = unsafe { &*(self.as_ptr() as *const atomic::$atomic) };
a.fetch_min(val, Ordering::AcqRel)
},
{
let _guard = lock(self.as_ptr() as usize).write();
Expand Down

0 comments on commit cb896e8

Please sign in to comment.