immediately register writer node if threads are queued

This commit is contained in:
joboet 2023-04-18 18:44:44 +02:00
parent 709ccf98b8
commit 61ce691522
No known key found for this signature in database
GPG Key ID: 704E0149B0194B3C

View File

@ -325,8 +325,9 @@ impl RwLock {
Ok(_) => return,
Err(new) => state = new,
}
} else if count < SPIN_COUNT {
// If the lock is not available, spin for a while.
} else if state.addr() & QUEUED == 0 && count < SPIN_COUNT {
// If the lock is not available but no threads are queued, spin
// for a while.
spin_loop();
state = self.state.load(Relaxed);
count += 1;