diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2022-04-01 11:11:28 +0200 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2022-04-01 11:11:28 +0200 |
| commit | 6392f1555e6515c59faa8393d1bf106b0c8872bd (patch) | |
| tree | 1f83e5bee0f8a0276dc64edb1e3c69f4eeada094 | |
| parent | c49887da277334226d17f7633392425e808b46d7 (diff) | |
| download | rust-6392f1555e6515c59faa8393d1bf106b0c8872bd.tar.gz rust-6392f1555e6515c59faa8393d1bf106b0c8872bd.zip | |
Shuffle around #[inline] and #[cold] in mutex impl.
| -rw-r--r-- | library/std/src/sys/unix/locks/futex.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/library/std/src/sys/unix/locks/futex.rs b/library/std/src/sys/unix/locks/futex.rs index ba37d58cc31..08c042f279b 100644 --- a/library/std/src/sys/unix/locks/futex.rs +++ b/library/std/src/sys/unix/locks/futex.rs @@ -38,6 +38,7 @@ impl Mutex { } } + #[cold] fn lock_contended(&self) { // Spin first to speed things up if the lock is released quickly. let mut state = self.spin(); @@ -91,9 +92,14 @@ impl Mutex { // will mark the mutex as contended (2) (see lock_contended above), // which makes sure that any other waiting threads will also be // woken up eventually. - futex_wake(&self.futex); + self.wake(); } } + + #[cold] + fn wake(&self) { + futex_wake(&self.futex); + } } pub struct Condvar { @@ -118,24 +124,20 @@ impl Condvar { // All the memory orderings here are `Relaxed`, // because synchronization is done by unlocking and locking the mutex. - #[inline] pub unsafe fn notify_one(&self) { self.futex.fetch_add(1, Relaxed); futex_wake(&self.futex); } - #[inline] pub unsafe fn notify_all(&self) { self.futex.fetch_add(1, Relaxed); futex_wake_all(&self.futex); } - #[inline] pub unsafe fn wait(&self, mutex: &Mutex) { self.wait_optional_timeout(mutex, None); } - #[inline] pub unsafe fn wait_timeout(&self, mutex: &Mutex, timeout: Duration) -> bool { self.wait_optional_timeout(mutex, Some(timeout)) } |
