replace deprecated compare_and_swap() with compare_exchange() (#1080)

This commit is contained in:
Rich Murphey 2021-03-03 10:50:12 -06:00 committed by GitHub
parent d5f9f08c62
commit edcc91c9f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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