Skip to content

Commit a55039d

Browse files
committed
Stabilize Arc::{incr,decr}_strong_count
1 parent 6340607 commit a55039d

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

library/alloc/src/sync.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -870,15 +870,13 @@ impl<T: ?Sized> Arc<T> {
870870
/// # Examples
871871
///
872872
/// ```
873-
/// #![feature(arc_mutate_strong_count)]
874-
///
875873
/// use std::sync::Arc;
876874
///
877875
/// let five = Arc::new(5);
878876
///
879877
/// unsafe {
880878
/// let ptr = Arc::into_raw(five);
881-
/// Arc::incr_strong_count(ptr);
879+
/// Arc::increment_strong_count(ptr);
882880
///
883881
/// // This assertion is deterministic because we haven't shared
884882
/// // the `Arc` between threads.
@@ -887,8 +885,8 @@ impl<T: ?Sized> Arc<T> {
887885
/// }
888886
/// ```
889887
#[inline]
890-
#[unstable(feature = "arc_mutate_strong_count", issue = "71983")]
891-
pub unsafe fn incr_strong_count(ptr: *const T) {
888+
#[stable(feature = "arc_mutate_strong_count", since = "1.50.0")]
889+
pub unsafe fn increment_strong_count(ptr: *const T) {
892890
// Retain Arc, but don't touch refcount by wrapping in ManuallyDrop
893891
let arc = unsafe { mem::ManuallyDrop::new(Arc::<T>::from_raw(ptr)) };
894892
// Now increase refcount, but don't drop new refcount either
@@ -909,27 +907,25 @@ impl<T: ?Sized> Arc<T> {
909907
/// # Examples
910908
///
911909
/// ```
912-
/// #![feature(arc_mutate_strong_count)]
913-
///
914910
/// use std::sync::Arc;
915911
///
916912
/// let five = Arc::new(5);
917913
///
918914
/// unsafe {
919915
/// let ptr = Arc::into_raw(five);
920-
/// Arc::incr_strong_count(ptr);
916+
/// Arc::increment_strong_count(ptr);
921917
///
922918
/// // Those assertions are deterministic because we haven't shared
923919
/// // the `Arc` between threads.
924920
/// let five = Arc::from_raw(ptr);
925921
/// assert_eq!(2, Arc::strong_count(&five));
926-
/// Arc::decr_strong_count(ptr);
922+
/// Arc::decrement_strong_count(ptr);
927923
/// assert_eq!(1, Arc::strong_count(&five));
928924
/// }
929925
/// ```
930926
#[inline]
931-
#[unstable(feature = "arc_mutate_strong_count", issue = "71983")]
932-
pub unsafe fn decr_strong_count(ptr: *const T) {
927+
#[stable(feature = "arc_mutate_strong_count", since = "1.50.0")]
928+
pub unsafe fn decrement_strong_count(ptr: *const T) {
933929
unsafe { mem::drop(Arc::from_raw(ptr)) };
934930
}
935931

library/alloc/src/task.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<W: Wake + Send + Sync + 'static> From<Arc<W>> for RawWaker {
6060
fn raw_waker<W: Wake + Send + Sync + 'static>(waker: Arc<W>) -> RawWaker {
6161
// Increment the reference count of the arc to clone it.
6262
unsafe fn clone_waker<W: Wake + Send + Sync + 'static>(waker: *const ()) -> RawWaker {
63-
unsafe { Arc::incr_strong_count(waker as *const W) };
63+
unsafe { Arc::increment_strong_count(waker as *const W) };
6464
RawWaker::new(
6565
waker as *const (),
6666
&RawWakerVTable::new(clone_waker::<W>, wake::<W>, wake_by_ref::<W>, drop_waker::<W>),
@@ -81,7 +81,7 @@ fn raw_waker<W: Wake + Send + Sync + 'static>(waker: Arc<W>) -> RawWaker {
8181

8282
// Decrement the reference count of the Arc on drop
8383
unsafe fn drop_waker<W: Wake + Send + Sync + 'static>(waker: *const ()) {
84-
unsafe { Arc::decr_strong_count(waker as *const W) };
84+
unsafe { Arc::decrement_strong_count(waker as *const W) };
8585
}
8686

8787
RawWaker::new(

0 commit comments

Comments
 (0)