Skip to content

Commit 7caf5fb

Browse files
authored
Rollup merge of rust-lang#72324 - Amanieu:atomic_minmax, r=dtolnay
Stabilize AtomicN::fetch_min and AtomicN::fetch_max Some architectures (ARMv8.1 LSE and RISC-V) have specific instructions for atomic min/max which the compiler can only generate through explicit instrinsics.
2 parents d7eed17 + 1d7a731 commit 7caf5fb

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/libcore/sync/atomic.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -1878,7 +1878,6 @@ using [`Release`] makes the load part [`Relaxed`].
18781878
# Examples
18791879
18801880
```
1881-
#![feature(atomic_min_max)]
18821881
", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};
18831882
18841883
let foo = ", stringify!($atomic_type), "::new(23);
@@ -1889,7 +1888,6 @@ assert_eq!(foo.load(Ordering::SeqCst), 42);
18891888
If you want to obtain the maximum value in one step, you can use the following:
18901889
18911890
```
1892-
#![feature(atomic_min_max)]
18931891
", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};
18941892
18951893
let foo = ", stringify!($atomic_type), "::new(23);
@@ -1898,9 +1896,7 @@ let max_foo = foo.fetch_max(bar, Ordering::SeqCst).max(bar);
18981896
assert!(max_foo == 42);
18991897
```"),
19001898
#[inline]
1901-
#[unstable(feature = "atomic_min_max",
1902-
reason = "easier and faster min/max than writing manual CAS loop",
1903-
issue = "48655")]
1899+
#[stable(feature = "atomic_min_max", since = "1.45.0")]
19041900
#[$cfg_cas]
19051901
pub fn fetch_max(&self, val: $int_type, order: Ordering) -> $int_type {
19061902
// SAFETY: data races are prevented by atomic intrinsics.
@@ -1929,7 +1925,6 @@ using [`Release`] makes the load part [`Relaxed`].
19291925
# Examples
19301926
19311927
```
1932-
#![feature(atomic_min_max)]
19331928
", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};
19341929
19351930
let foo = ", stringify!($atomic_type), "::new(23);
@@ -1942,7 +1937,6 @@ assert_eq!(foo.load(Ordering::Relaxed), 22);
19421937
If you want to obtain the minimum value in one step, you can use the following:
19431938
19441939
```
1945-
#![feature(atomic_min_max)]
19461940
", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};
19471941
19481942
let foo = ", stringify!($atomic_type), "::new(23);
@@ -1951,9 +1945,7 @@ let min_foo = foo.fetch_min(bar, Ordering::SeqCst).min(bar);
19511945
assert_eq!(min_foo, 12);
19521946
```"),
19531947
#[inline]
1954-
#[unstable(feature = "atomic_min_max",
1955-
reason = "easier and faster min/max than writing manual CAS loop",
1956-
issue = "48655")]
1948+
#[stable(feature = "atomic_min_max", since = "1.45.0")]
19571949
#[$cfg_cas]
19581950
pub fn fetch_min(&self, val: $int_type, order: Ordering) -> $int_type {
19591951
// SAFETY: data races are prevented by atomic intrinsics.

0 commit comments

Comments
 (0)