Skip to content

Fix spin_loop_hint warning on Rust 1.51 #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- Fix `spin_loop_hint` warning on Rust 1.51

# 0.2.2 – 2020-08-24

- Add owning_ref support ([#7](https://github.com/rust-osdev/spinning_top/pull/7))
Expand Down
7 changes: 5 additions & 2 deletions src/spinlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
// and
// https://github.com/mvdnes/spin-rs/tree/7516c8037d3d15712ba4d8499ab075e97a19d778

use core::sync::atomic::{spin_loop_hint, AtomicBool, Ordering};
use core::{
hint,
sync::atomic::{AtomicBool, Ordering},
};
use lock_api::{GuardSend, RawMutex};

/// Provides mutual exclusion based on spinning on an `AtomicBool`.
Expand Down Expand Up @@ -51,7 +54,7 @@ unsafe impl RawMutex for RawSpinlock {
// Code from https://github.com/mvdnes/spin-rs/commit/d3e60d19adbde8c8e9d3199c7c51e51ee5a20bf6
while self.is_locked() {
// Tell the CPU that we're inside a busy-wait loop
spin_loop_hint();
hint::spin_loop();
}
}
}
Expand Down