@@ -38,6 +38,7 @@ impl Mutex {
38
38
}
39
39
}
40
40
41
+ #[ cold]
41
42
fn lock_contended ( & self ) {
42
43
// Spin first to speed things up if the lock is released quickly.
43
44
let mut state = self . spin ( ) ;
@@ -91,9 +92,14 @@ impl Mutex {
91
92
// will mark the mutex as contended (2) (see lock_contended above),
92
93
// which makes sure that any other waiting threads will also be
93
94
// woken up eventually.
94
- futex_wake ( & self . futex ) ;
95
+ self . wake ( ) ;
95
96
}
96
97
}
98
+
99
+ #[ cold]
100
+ fn wake ( & self ) {
101
+ futex_wake ( & self . futex ) ;
102
+ }
97
103
}
98
104
99
105
pub struct Condvar {
@@ -118,24 +124,20 @@ impl Condvar {
118
124
// All the memory orderings here are `Relaxed`,
119
125
// because synchronization is done by unlocking and locking the mutex.
120
126
121
- #[ inline]
122
127
pub unsafe fn notify_one ( & self ) {
123
128
self . futex . fetch_add ( 1 , Relaxed ) ;
124
129
futex_wake ( & self . futex ) ;
125
130
}
126
131
127
- #[ inline]
128
132
pub unsafe fn notify_all ( & self ) {
129
133
self . futex . fetch_add ( 1 , Relaxed ) ;
130
134
futex_wake_all ( & self . futex ) ;
131
135
}
132
136
133
- #[ inline]
134
137
pub unsafe fn wait ( & self , mutex : & Mutex ) {
135
138
self . wait_optional_timeout ( mutex, None ) ;
136
139
}
137
140
138
- #[ inline]
139
141
pub unsafe fn wait_timeout ( & self , mutex : & Mutex , timeout : Duration ) -> bool {
140
142
self . wait_optional_timeout ( mutex, Some ( timeout) )
141
143
}
0 commit comments