Don't spin on contended mutexes.
This commit is contained in:
parent
6392f1555e
commit
321690c827
@ -76,7 +76,9 @@ impl Mutex {
|
||||
// while spinning, to be easier on the caches.
|
||||
let state = self.futex.load(Relaxed);
|
||||
|
||||
if state == 0 || spin == 0 {
|
||||
// We stop spinning when the mutex is unlocked (0),
|
||||
// but also when it's contended (2).
|
||||
if state != 1 || spin == 0 {
|
||||
return state;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user