Skip to content

Commit

Permalink
clean up listener @ None patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
SNCPlay42 committed May 26, 2023
1 parent f675c23 commit ebe85d9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,9 @@ impl<T: ?Sized, B: Unpin + Borrow<Mutex<T>>> Future for AcquireSlow<B, T> {
loop {
// Start listening for events.
match &mut this.listener {
listener @ None => {
None => {
// Start listening for events.
*listener = Some(mutex.lock_ops.listen());
this.listener = Some(mutex.lock_ops.listen());

// Try locking if nobody is being starved.
match mutex
Expand Down Expand Up @@ -490,9 +490,9 @@ impl<T: ?Sized, B: Unpin + Borrow<Mutex<T>>> Future for AcquireSlow<B, T> {
// Fairer locking loop.
loop {
match &mut this.listener {
listener @ None => {
None => {
// Start listening for events.
*listener = Some(mutex.lock_ops.listen());
this.listener = Some(mutex.lock_ops.listen());

// Try locking if nobody else is being starved.
match mutex
Expand Down
8 changes: 4 additions & 4 deletions src/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ impl<'a, T: ?Sized> Future for Read<'a, T> {
} else {
// Start listening for "no writer" events.
let load_ordering = match &mut this.listener {
listener @ None => {
*listener = Some(this.lock.no_writer.listen());
None => {
this.listener = Some(this.lock.no_writer.listen());

// Make sure there really is no writer.
Ordering::SeqCst
Expand Down Expand Up @@ -823,9 +823,9 @@ impl<'a, T: ?Sized> Future for Upgrade<'a, T> {

// If there are readers, wait for them to finish.
match &mut this.listener {
listener @ None => {
None => {
// Start listening for "no readers" events.
*listener = Some(guard.writer.0.no_readers.listen());
this.listener = Some(guard.writer.0.no_readers.listen());
}

Some(ref mut listener) => {
Expand Down
8 changes: 4 additions & 4 deletions src/semaphore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ impl<'a> Future for Acquire<'a> {
None => {
// Wait on the listener.
match &mut this.listener {
listener @ None => {
*listener = Some(this.semaphore.event.listen());
None => {
this.listener = Some(this.semaphore.event.listen());
}
Some(ref mut listener) => {
ready!(Pin::new(listener).poll(cx));
Expand Down Expand Up @@ -229,8 +229,8 @@ impl Future for AcquireArc {
None => {
// Wait on the listener.
match &mut this.listener {
listener @ None => {
*listener = Some(this.semaphore.event.listen());
None => {
this.listener = Some(this.semaphore.event.listen());
}
Some(ref mut listener) => {
ready!(Pin::new(listener).poll(cx));
Expand Down

0 comments on commit ebe85d9

Please sign in to comment.