File tree Expand file tree Collapse file tree 4 files changed +19
-20
lines changed Expand file tree Collapse file tree 4 files changed +19
-20
lines changed Original file line number Diff line number Diff line change @@ -370,7 +370,7 @@ fn test_weak_count_locked() {
370370 let n = Arc :: weak_count ( & a2) ;
371371 assert ! ( n < 2 , "bad weak count: {}" , n) ;
372372 #[ cfg( miri) ] // Miri's scheduler does not guarantee liveness, and thus needs this hint.
373- atomic :: spin_loop_hint ( ) ;
373+ std :: hint :: spin_loop ( ) ;
374374 }
375375 t. join ( ) . unwrap ( ) ;
376376}
Original file line number Diff line number Diff line change @@ -120,21 +120,6 @@ use crate::intrinsics;
120120
121121use crate :: hint:: spin_loop;
122122
123- /// Signals the processor that it is inside a busy-wait spin-loop ("spin lock").
124- ///
125- /// This function is expected to be deprecated in favor of
126- /// [`hint::spin_loop`].
127- ///
128- /// **Note**: On platforms that do not support receiving spin-loop hints this function does not
129- /// do anything at all.
130- ///
131- /// [`hint::spin_loop`]: crate::hint::spin_loop
132- #[ inline]
133- #[ stable( feature = "spin_loop_hint" , since = "1.24.0" ) ]
134- pub fn spin_loop_hint ( ) {
135- spin_loop ( )
136- }
137-
138123/// A boolean type which can be safely shared between threads.
139124///
140125/// This type has the same in-memory representation as a [`bool`].
@@ -2791,3 +2776,15 @@ impl<T> fmt::Pointer for AtomicPtr<T> {
27912776 fmt:: Pointer :: fmt ( & self . load ( Ordering :: SeqCst ) , f)
27922777 }
27932778}
2779+
2780+ /// Signals the processor that it is inside a busy-wait spin-loop ("spin lock").
2781+ ///
2782+ /// This function is deprecated in favor of [`hint::spin_loop`].
2783+ ///
2784+ /// [`hint::spin_loop`]: crate::hint::spin_loop
2785+ #[ inline]
2786+ #[ stable( feature = "spin_loop_hint" , since = "1.24.0" ) ]
2787+ #[ rustc_deprecated( since = "1.51.0" , reason = "use hint::spin_loop instead" ) ]
2788+ pub fn spin_loop_hint ( ) {
2789+ spin_loop ( )
2790+ }
Original file line number Diff line number Diff line change 11use crate :: cell:: UnsafeCell ;
22use crate :: collections:: VecDeque ;
33use crate :: ffi:: c_void;
4+ use crate :: hint;
45use crate :: ops:: { Deref , DerefMut , Drop } ;
56use crate :: ptr;
6- use crate :: sync:: atomic:: { spin_loop_hint , AtomicUsize , Ordering } ;
7+ use crate :: sync:: atomic:: { AtomicUsize , Ordering } ;
78use crate :: sys:: hermit:: abi;
89
910/// This type provides a lock based on busy waiting to realize mutual exclusion
@@ -46,7 +47,7 @@ impl<T> Spinlock<T> {
4647 fn obtain_lock ( & self ) {
4748 let ticket = self . queue . fetch_add ( 1 , Ordering :: SeqCst ) + 1 ;
4849 while self . dequeue . load ( Ordering :: SeqCst ) != ticket {
49- spin_loop_hint ( ) ;
50+ hint :: spin_loop ( ) ;
5051 }
5152 }
5253
Original file line number Diff line number Diff line change 22mod tests;
33
44use crate :: cell:: UnsafeCell ;
5+ use crate :: hint;
56use crate :: ops:: { Deref , DerefMut } ;
6- use crate :: sync:: atomic:: { spin_loop_hint , AtomicBool , Ordering } ;
7+ use crate :: sync:: atomic:: { AtomicBool , Ordering } ;
78
89#[ derive( Default ) ]
910pub struct SpinMutex < T > {
@@ -32,7 +33,7 @@ impl<T> SpinMutex<T> {
3233 match self . try_lock ( ) {
3334 None => {
3435 while self . lock . load ( Ordering :: Relaxed ) {
35- spin_loop_hint ( )
36+ hint :: spin_loop ( )
3637 }
3738 }
3839 Some ( guard) => return guard,
You can’t perform that action at this time.
0 commit comments