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:
parent
460aeb32e2
commit
7167a5e44d
2 changed files with 3 additions and 15 deletions
2
.github/workflows/oxipng.yml
vendored
2
.github/workflows/oxipng.yml
vendored
|
|
@ -19,7 +19,7 @@ jobs:
|
|||
- x86_64-apple-darwin
|
||||
toolchain:
|
||||
# Minimum stable
|
||||
- "1.41.0"
|
||||
- "1.45.0"
|
||||
- stable
|
||||
- beta
|
||||
- nightly
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue