be more explicit about why adding backlinks eagerly makes sense
This commit is contained in:
parent
69f55de5ac
commit
3fa5a40737
@ -91,11 +91,12 @@
|
|||||||
//!
|
//!
|
||||||
//! Access to the queue is controlled by the `QUEUE_LOCKED` bit, which threads
|
//! Access to the queue is controlled by the `QUEUE_LOCKED` bit, which threads
|
||||||
//! try to set both after enqueuing themselves to eagerly add backlinks to the
|
//! try to set both after enqueuing themselves to eagerly add backlinks to the
|
||||||
//! queue and after unlocking the lock to wake the next waiter(s). This is done
|
//! queue, which drastically improves performance, and after unlocking the lock
|
||||||
//! atomically at the same time as the enqueuing/unlocking operation. The thread
|
//! to wake the next waiter(s). This is done atomically at the same time as the
|
||||||
//! releasing the `QUEUE_LOCK` bit will check the state of the lock and wake up
|
//! enqueuing/unlocking operation. The thread releasing the `QUEUE_LOCK` bit
|
||||||
//! waiters as appropriate. This guarantees forward-progress even if the unlocking
|
//! will check the state of the lock and wake up waiters as appropriate. This
|
||||||
//! thread could not acquire the queue lock.
|
//! guarantees forward-progress even if the unlocking thread could not acquire
|
||||||
|
//! the queue lock.
|
||||||
//!
|
//!
|
||||||
//! ## Memory orderings
|
//! ## Memory orderings
|
||||||
//!
|
//!
|
||||||
@ -358,7 +359,7 @@ impl RwLock {
|
|||||||
} else {
|
} else {
|
||||||
// Otherwise, the tail of the queue is not known.
|
// Otherwise, the tail of the queue is not known.
|
||||||
node.tail.set(None);
|
node.tail.set(None);
|
||||||
// Try locking the queue to fully link it.
|
// Try locking the queue to eagerly add backlinks.
|
||||||
next = next.map_addr(|addr| addr | QUEUE_LOCKED);
|
next = next.map_addr(|addr| addr | QUEUE_LOCKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user