Skip to content

Commit

Permalink
format using latest rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
joboet committed Feb 9, 2024
1 parent 1fd9f78 commit 69f55de
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions library/std/src/sys/pal/unix/locks/queue_rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,9 @@ impl RwLock {
// `state`, so the first non-null tail field will be current
// (invariant 2). Invariant 4 is fullfilled since `find_tail`
// was called on this node, which ensures all backlinks are set.
unsafe { to_node(state).as_ref().tail.set(Some(prev)); }
unsafe {
to_node(state).as_ref().tail.set(Some(prev));
}

// Release the queue lock. Doing this by subtraction is more
// efficient on modern processors since it is a single instruction
Expand All @@ -520,22 +522,28 @@ impl RwLock {

// The tail was split off and the lock released. Mark the node as
// completed.
unsafe { return Node::complete(tail); }
unsafe {
return Node::complete(tail);
}
} else {
// The next waiter is a reader or the queue only consists of one
// waiter. Just wake all threads.

// The lock cannot be locked (checked above), so mark it as
// unlocked to reset the queue.
if let Err(new) = self.state.compare_exchange_weak(state, UNLOCKED, Release, Acquire) {
if let Err(new) =
self.state.compare_exchange_weak(state, UNLOCKED, Release, Acquire)
{
state = new;
continue;
}

let mut current = tail;
loop {
let prev = unsafe { current.as_ref().prev.get() };
unsafe { Node::complete(current); }
unsafe {
Node::complete(current);
}
match prev {
Some(prev) => current = prev,
None => return,
Expand Down

0 comments on commit 69f55de

Please sign in to comment.