Skip to content
This repository was archived by the owner on Apr 4, 2024. It is now read-only.

Commit 6cd91d5

Browse files
author
Chojan Shang
authored
bump deps and make clippy happy (#57)
- rand 0.8 - `#[allow(clippy::vtable_address_comparisons)]` for SyncCallback - `compare_and_swap` -> `compare_exchange_weak`, because of `#[warn(deprecated)]` Signed-off-by: Chojan Shang <[email protected]>
1 parent e54fded commit 6cd91d5

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ exclude = ["/.github/*", "/.travis.yml", "/appveyor.yml"]
1616
[dependencies]
1717
log = { version = "0.4", features = ["std"] }
1818
lazy_static = "1.2"
19-
rand = "0.7"
19+
rand = "0.8"
2020

2121
[features]
2222
failpoints = []

src/lib.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ impl Debug for SyncCallback {
244244
}
245245

246246
impl PartialEq for SyncCallback {
247+
#[allow(clippy::vtable_address_comparisons)]
247248
fn eq(&self, other: &Self) -> bool {
248249
Arc::ptr_eq(&self.0, &other.0)
249250
}
@@ -336,14 +337,21 @@ impl Action {
336337
if self.freq < 1f32 && !rand::thread_rng().gen_bool(f64::from(self.freq)) {
337338
return None;
338339
}
339-
if let Some(ref cnt) = self.count {
340+
if let Some(ref ref_cnt) = self.count {
341+
let mut cnt = ref_cnt.load(Ordering::Acquire);
340342
loop {
341-
let c = cnt.load(Ordering::Acquire);
342-
if c == 0 {
343+
if cnt == 0 {
343344
return None;
344345
}
345-
if c == cnt.compare_and_swap(c, c - 1, Ordering::AcqRel) {
346-
break;
346+
let new_cnt = cnt - 1;
347+
match ref_cnt.compare_exchange_weak(
348+
cnt,
349+
new_cnt,
350+
Ordering::AcqRel,
351+
Ordering::Acquire,
352+
) {
353+
Ok(_) => break,
354+
Err(c) => cnt = c,
347355
}
348356
}
349357
}

0 commit comments

Comments
 (0)