@@ -38,6 +38,7 @@ impl Mutex {
3838 }
3939 }
4040
41+ #[ cold]
4142 fn lock_contended ( & self ) {
4243 // Spin first to speed things up if the lock is released quickly.
4344 let mut state = self . spin ( ) ;
@@ -91,9 +92,14 @@ impl Mutex {
9192 // will mark the mutex as contended (2) (see lock_contended above),
9293 // which makes sure that any other waiting threads will also be
9394 // woken up eventually.
94- futex_wake ( & self . futex ) ;
95+ self . wake ( ) ;
9596 }
9697 }
98+
99+ #[ cold]
100+ fn wake ( & self ) {
101+ futex_wake ( & self . futex ) ;
102+ }
97103}
98104
99105pub struct Condvar {
@@ -118,24 +124,20 @@ impl Condvar {
118124 // All the memory orderings here are `Relaxed`,
119125 // because synchronization is done by unlocking and locking the mutex.
120126
121- #[ inline]
122127 pub unsafe fn notify_one ( & self ) {
123128 self . futex . fetch_add ( 1 , Relaxed ) ;
124129 futex_wake ( & self . futex ) ;
125130 }
126131
127- #[ inline]
128132 pub unsafe fn notify_all ( & self ) {
129133 self . futex . fetch_add ( 1 , Relaxed ) ;
130134 futex_wake_all ( & self . futex ) ;
131135 }
132136
133- #[ inline]
134137 pub unsafe fn wait ( & self , mutex : & Mutex ) {
135138 self . wait_optional_timeout ( mutex, None ) ;
136139 }
137140
138- #[ inline]
139141 pub unsafe fn wait_timeout ( & self , mutex : & Mutex , timeout : Duration ) -> bool {
140142 self . wait_optional_timeout ( mutex, Some ( timeout) )
141143 }
0 commit comments