File tree 4 files changed +19
-20
lines changed
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() {
370
370
let n = Arc :: weak_count ( & a2) ;
371
371
assert ! ( n < 2 , "bad weak count: {}" , n) ;
372
372
#[ cfg( miri) ] // Miri's scheduler does not guarantee liveness, and thus needs this hint.
373
- atomic :: spin_loop_hint ( ) ;
373
+ std :: hint :: spin_loop ( ) ;
374
374
}
375
375
t. join ( ) . unwrap ( ) ;
376
376
}
Original file line number Diff line number Diff line change @@ -120,21 +120,6 @@ use crate::intrinsics;
120
120
121
121
use crate :: hint:: spin_loop;
122
122
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
-
138
123
/// A boolean type which can be safely shared between threads.
139
124
///
140
125
/// This type has the same in-memory representation as a [`bool`].
@@ -2791,3 +2776,15 @@ impl<T> fmt::Pointer for AtomicPtr<T> {
2791
2776
fmt:: Pointer :: fmt ( & self . load ( Ordering :: SeqCst ) , f)
2792
2777
}
2793
2778
}
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 1
1
use crate :: cell:: UnsafeCell ;
2
2
use crate :: collections:: VecDeque ;
3
3
use crate :: ffi:: c_void;
4
+ use crate :: hint;
4
5
use crate :: ops:: { Deref , DerefMut , Drop } ;
5
6
use crate :: ptr;
6
- use crate :: sync:: atomic:: { spin_loop_hint , AtomicUsize , Ordering } ;
7
+ use crate :: sync:: atomic:: { AtomicUsize , Ordering } ;
7
8
use crate :: sys:: hermit:: abi;
8
9
9
10
/// This type provides a lock based on busy waiting to realize mutual exclusion
@@ -46,7 +47,7 @@ impl<T> Spinlock<T> {
46
47
fn obtain_lock ( & self ) {
47
48
let ticket = self . queue . fetch_add ( 1 , Ordering :: SeqCst ) + 1 ;
48
49
while self . dequeue . load ( Ordering :: SeqCst ) != ticket {
49
- spin_loop_hint ( ) ;
50
+ hint :: spin_loop ( ) ;
50
51
}
51
52
}
52
53
Original file line number Diff line number Diff line change 2
2
mod tests;
3
3
4
4
use crate :: cell:: UnsafeCell ;
5
+ use crate :: hint;
5
6
use crate :: ops:: { Deref , DerefMut } ;
6
- use crate :: sync:: atomic:: { spin_loop_hint , AtomicBool , Ordering } ;
7
+ use crate :: sync:: atomic:: { AtomicBool , Ordering } ;
7
8
8
9
#[ derive( Default ) ]
9
10
pub struct SpinMutex < T > {
@@ -32,7 +33,7 @@ impl<T> SpinMutex<T> {
32
33
match self . try_lock ( ) {
33
34
None => {
34
35
while self . lock . load ( Ordering :: Relaxed ) {
35
- spin_loop_hint ( )
36
+ hint :: spin_loop ( )
36
37
}
37
38
}
38
39
Some ( guard) => return guard,
You can’t perform that action at this time.
0 commit comments