Use the new stabilised fetch_min (#328)

A minor simplification using the corresponding new standard library function.

Bumps minimum Rust version to 1.45.0
This commit is contained in:
Ingvar Stepanyan 2020-10-11 23:53:00 +01:00 committed by GitHub
parent 460aeb32e2
commit 7167a5e44d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 15 deletions

View file

@ -19,7 +19,7 @@ jobs:
- x86_64-apple-darwin
toolchain:
# Minimum stable
- "1.41.0"
- "1.45.0"
- stable
- beta
- nightly

View file

@ -1,5 +1,5 @@
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::{Relaxed, SeqCst};
use std::sync::atomic::Ordering::SeqCst;
#[derive(Debug)]
pub struct AtomicMin {
@ -28,18 +28,6 @@ impl AtomicMin {
}
pub fn set_min(&self, new_val: usize) {
let mut current_val = self.val.load(Relaxed);
loop {
if new_val < current_val {
if let Err(v) = self
.val
.compare_exchange(current_val, new_val, SeqCst, Relaxed)
{
current_val = v;
continue;
}
}
break;
}
self.val.fetch_min(new_val, SeqCst);
}
}