Skip to content

Commit

Permalink
Replace deprecated spin_loop_hint.
Browse files Browse the repository at this point in the history
sled requires Rust 1.62+ and `spin_loop` is availabe starting
in 1.42.
  • Loading branch information
ttsugriy committed Sep 4, 2023
1 parent 005c023 commit b20a393
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
5 changes: 1 addition & 4 deletions src/backoff.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/// Vendored and simplified from crossbeam-utils
use core::cell::Cell;
use core::sync::atomic;

const SPIN_LIMIT: u32 = 6;

Expand Down Expand Up @@ -31,9 +30,7 @@ impl Backoff {
#[inline]
pub fn spin(&self) {
for _ in 0..1 << self.step.get().min(SPIN_LIMIT) {
// `hint::spin_loop` requires Rust 1.49.
#[allow(deprecated)]
atomic::spin_loop_hint();
core::hint::spin_loop();
}

if self.step.get() <= SPIN_LIMIT {
Expand Down
8 changes: 2 additions & 6 deletions src/concurrency_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ impl ConcurrencyControl {
if self.active.fetch_or(RW_REQUIRED_BIT, SeqCst) < RW_REQUIRED_BIT {
// we are the first to set this bit
while self.active.load(Acquire) != RW_REQUIRED_BIT {
// `hint::spin_loop` requires Rust 1.49.
#[allow(deprecated)]
std::sync::atomic::spin_loop_hint()
std::hint::spin_loop()
}
self.upgrade_complete.store(true, Release);
}
Expand Down Expand Up @@ -99,9 +97,7 @@ impl ConcurrencyControl {
});
self.enable();
while !self.upgrade_complete.load(Acquire) {
// `hint::spin_loop` requires Rust 1.49.
#[allow(deprecated)]
std::sync::atomic::spin_loop_hint()
std::hint::spin_loop()
}
Protector::Write(self.rw.write())
}
Expand Down

0 comments on commit b20a393

Please sign in to comment.