Skip to content

Commit

Permalink
replace deprecated compare_and_swap() with compare_exchange() (#1080)
Browse files Browse the repository at this point in the history
  • Loading branch information
rich-murphey authored Mar 3, 2021
1 parent d5f9f08 commit edcc91c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sqlx-core/src/pool/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ impl<DB: Database> SharedPool<DB> {
let mut size = self.size();

while size < self.options.max_connections {
let new_size = self.size.compare_and_swap(size, size + 1, Ordering::AcqRel);

if new_size == size {
return Some(DecrementSizeGuard::new(self));
match self
.size
.compare_exchange(size, size + 1, Ordering::AcqRel, Ordering::Acquire)
{
Ok(_) => return Some(DecrementSizeGuard::new(self)),
Err(new_size) => size = new_size,
}

size = new_size;
}

None
Expand Down

0 comments on commit edcc91c

Please sign in to comment.