Skip to content
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

Use core::hint::spin_loop instead of the deprecated spin_loop_hint. #314

Merged
merged 2 commits into from Jan 28, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/rust.yml
Expand Up @@ -2,11 +2,11 @@ name: Rust

on:
push:
branches-ignore:
- trying.tmp
- staging.tmp
branches:
- trying
- staging
pull_request:

env:
RUST_TEST_THREADS: 1

Expand All @@ -16,11 +16,11 @@ jobs:
strategy:
matrix:
os: [ubuntu, macos, windows]
channel: [1.41.0, stable, beta, nightly]
channel: [1.49.0, stable, beta, nightly]
feature: [arc_lock, serde, deadlock_detection]
exclude:
- feature: deadlock_detection
channel: '1.41.0'
channel: '1.49.0'
include:
- channel: nightly
feature: nightly
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -135,7 +135,7 @@ changes to the core API do not cause breaking changes for users of `parking_lot`

## Minimum Rust version

The current minimum required Rust version is 1.41. Any change to this is
The current minimum required Rust version is 1.49. Any change to this is
considered a breaking change and will require a major version bump.

## License
Expand Down
4 changes: 2 additions & 2 deletions core/src/spinwait.rs
Expand Up @@ -6,14 +6,14 @@
// copied, modified, or distributed except according to those terms.

use crate::thread_parker;
use std::sync::atomic::spin_loop_hint;
use core::hint::spin_loop;

// Wastes some CPU time for the given number of iterations,
// using a hint to indicate to the CPU that we are spinning.
#[inline]
fn cpu_relax(iterations: u32) {
for _ in 0..iterations {
spin_loop_hint()
spin_loop()
}
}

Expand Down
7 changes: 4 additions & 3 deletions core/src/thread_parker/generic.rs
Expand Up @@ -8,7 +8,8 @@
//! A simple spin lock based thread parker. Used on platforms without better
//! parking facilities available.

use core::sync::atomic::{spin_loop_hint, AtomicBool, Ordering};
use core::sync::atomic::{AtomicBool, Ordering};
use core::hint::spin_loop;
use std::thread;
use std::time::Instant;

Expand Down Expand Up @@ -42,7 +43,7 @@ impl super::ThreadParkerT for ThreadParker {
#[inline]
unsafe fn park(&self) {
while self.parked.load(Ordering::Acquire) != false {
spin_loop_hint();
spin_loop();
}
}

Expand All @@ -52,7 +53,7 @@ impl super::ThreadParkerT for ThreadParker {
if Instant::now() >= timeout {
return false;
}
spin_loop_hint();
spin_loop();
}
true
}
Expand Down