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 Nov 5, 2023
1 parent a08a3d6 commit e921d2c
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 @@ -705,8 +705,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 @@ -736,8 +736,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 e921d2c

Please sign in to comment.