Skip to content

Commit

Permalink
Update dependencies & bump MSRV to 1.56.0 (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
westy92 authored Jan 30, 2024
1 parent 2c1cc2d commit 3dcdfea
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 36 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ jobs:
strategy:
matrix:
os: [ubuntu, macos, windows]
channel: [1.49.0, stable, beta, nightly]
channel: [1.56.0, stable, beta, nightly]
feature: [arc_lock, serde, deadlock_detection]
exclude:
- feature: deadlock_detection
channel: '1.49.0'
channel: '1.56.0'
# Versions before 1.54 fail to build on the latest XCode.
- os: macos
channel: '1.49.0'
channel: '1.56.0'
include:
- channel: nightly
feature: nightly
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ repository = "https://github.com/Amanieu/parking_lot"
readme = "README.md"
keywords = ["mutex", "condvar", "rwlock", "once", "thread"]
categories = ["concurrency"]
edition = "2018"
rust-version = "1.49"
edition = "2021"
rust-version = "1.56"

[package.metadata.docs.rs]
features = ["arc_lock", "serde", "deadlock_detection"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,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.49. Any change to this is
The current minimum required Rust version is 1.56. 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 benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
name = "parking_lot-benchmark"
version = "0.0.0"
authors = ["Amanieu d'Antras <[email protected]>"]
edition = "2018"
edition = "2021"

[dependencies]
parking_lot = {path = ".."}
seqlock = "0.1"
seqlock = "0.2"
libc = "0.2"

[[bin]]
Expand Down
6 changes: 3 additions & 3 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ license = "MIT OR Apache-2.0"
repository = "https://github.com/Amanieu/parking_lot"
keywords = ["mutex", "condvar", "rwlock", "once", "thread"]
categories = ["concurrency"]
edition = "2018"
rust-version = "1.49.0"
edition = "2021"
rust-version = "1.56.0"

[package.metadata.docs.rs]
rustdoc-args = ["--generate-link-to-definition"]
Expand All @@ -27,7 +27,7 @@ libc = "0.2.95"
redox_syscall = "0.4"

[target.'cfg(windows)'.dependencies]
windows-targets = "0.48.0"
windows-targets = "0.52.0"

[features]
nightly = []
Expand Down
21 changes: 18 additions & 3 deletions core/src/thread_parker/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.

#[cfg(any(target_os = "macos", target_os = "tvos", target_os = "ios", target_os = "watchos"))]
#[cfg(any(
target_os = "macos",
target_os = "tvos",
target_os = "ios",
target_os = "watchos"
))]
use core::ptr;
use core::{
cell::{Cell, UnsafeCell},
Expand Down Expand Up @@ -197,7 +202,12 @@ impl super::UnparkHandleT for UnparkHandle {
}

// Returns the current time on the clock used by pthread_cond_t as a timespec.
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
#[cfg(any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "watchos"
))]
#[inline]
fn timespec_now() -> libc::timespec {
let mut now = MaybeUninit::<libc::timeval>::uninit();
Expand All @@ -210,7 +220,12 @@ fn timespec_now() -> libc::timespec {
tv_nsec: now.tv_usec as tv_nsec_t * 1000,
}
}
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos")))]
#[cfg(not(any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "watchos"
)))]
#[inline]
fn timespec_now() -> libc::timespec {
let mut now = MaybeUninit::<libc::timespec>::uninit();
Expand Down
4 changes: 2 additions & 2 deletions lock_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ license = "MIT OR Apache-2.0"
repository = "https://github.com/Amanieu/parking_lot"
keywords = ["mutex", "rwlock", "lock", "no_std"]
categories = ["concurrency", "no-std"]
edition = "2018"
rust-version = "1.49.0"
edition = "2021"
rust-version = "1.56.0"

[package.metadata.docs.rs]
all-features = true
Expand Down
18 changes: 9 additions & 9 deletions src/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ mod tests {
let data = data.clone();
let tx = tx.clone();
thread::spawn(move || {
let &(ref lock, ref cond) = &*data;
let (lock, cond) = &*data;
let mut cnt = lock.lock();
*cnt += 1;
if *cnt == N {
Expand All @@ -579,7 +579,7 @@ mod tests {
}
drop(tx);

let &(ref lock, ref cond) = &*data;
let (lock, cond) = &*data;
rx.recv().unwrap();
let mut cnt = lock.lock();
*cnt = 0;
Expand Down Expand Up @@ -627,7 +627,7 @@ mod tests {
let data = data.clone();
let tx = tx.clone();
thread::spawn(move || {
let &(ref lock, ref cond) = &*data;
let (lock, cond) = &*data;
let mut cnt = lock.lock();
*cnt += 1;
if *cnt == N {
Expand All @@ -641,7 +641,7 @@ mod tests {
}
drop(tx);

let &(ref lock, ref cond) = &*data;
let (lock, cond) = &*data;
rx.recv().unwrap();
let mut cnt = lock.lock();
*cnt = 0;
Expand Down Expand Up @@ -832,7 +832,7 @@ mod tests {
drop(g);
rx.recv().unwrap();
let _g = m.lock();
let _guard = PanicGuard(&*c);
let _guard = PanicGuard(&c);
c.wait(&mut m3.lock());
}

Expand Down Expand Up @@ -1054,7 +1054,7 @@ mod webkit_queue_test {
let (should_notify, result) = {
let mut queue = input_queue.lock();
wait(
&*empty_condition,
&empty_condition,
&mut queue,
|state| -> bool { !state.items.is_empty() || !state.should_continue },
&timeout,
Expand All @@ -1067,7 +1067,7 @@ mod webkit_queue_test {
std::mem::drop(queue);
(should_notify, result)
};
notify(notify_style, &*full_condition, should_notify);
notify(notify_style, &full_condition, should_notify);

if let Some(result) = result {
output_queue.lock().push(result);
Expand All @@ -1089,7 +1089,7 @@ mod webkit_queue_test {
let should_notify = {
let mut queue = queue.lock();
wait(
&*full_condition,
&full_condition,
&mut queue,
|state| state.items.len() < max_queue_size,
&timeout,
Expand All @@ -1099,7 +1099,7 @@ mod webkit_queue_test {
std::mem::drop(queue);
should_notify
};
notify(notify_style, &*empty_condition, should_notify);
notify(notify_style, &empty_condition, should_notify);
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,13 @@ mod tests {
let _t = thread::spawn(move || {
// wait until parent gets in
rx.recv().unwrap();
let &(ref lock, ref cvar) = &*packet2.0;
let (lock, cvar) = &*packet2.0;
let mut lock = lock.lock();
*lock = true;
cvar.notify_one();
});

let &(ref lock, ref cvar) = &*packet.0;
let (lock, cvar) = &*packet.0;
let mut lock = lock.lock();
tx.send(()).unwrap();
assert!(!*lock);
Expand Down
10 changes: 2 additions & 8 deletions src/once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,14 @@ impl OnceState {
/// indicate to future forced initialization routines that it is poisoned.
#[inline]
pub fn poisoned(self) -> bool {
match self {
OnceState::Poisoned => true,
_ => false,
}
matches!(self, OnceState::Poisoned)
}

/// Returns whether the associated `Once` has successfully executed a
/// closure.
#[inline]
pub fn done(self) -> bool {
match self {
OnceState::Done => true,
_ => false,
}
matches!(self, OnceState::Done)
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/raw_rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ unsafe impl lock_api::RawRwLockUpgrade for RawRwLock {
unsafe fn unlock_upgradable(&self) {
self.deadlock_release();
let state = self.state.load(Ordering::Relaxed);
#[allow(clippy::collapsible_if)]
if state & PARKED_BIT == 0 {
if self
.state
Expand Down Expand Up @@ -399,6 +400,7 @@ unsafe impl lock_api::RawRwLockUpgradeFair for RawRwLock {
unsafe fn unlock_upgradable_fair(&self) {
self.deadlock_release();
let state = self.state.load(Ordering::Relaxed);
#[allow(clippy::collapsible_if)]
if state & PARKED_BIT == 0 {
if self
.state
Expand Down Expand Up @@ -540,6 +542,7 @@ impl RawRwLock {
let mut state = self.state.load(Ordering::Relaxed);
loop {
// This mirrors the condition in try_lock_shared_fast
#[allow(clippy::collapsible_if)]
if state & WRITER_BIT != 0 {
if !recursive || state & READERS_MASK == 0 {
return false;
Expand Down Expand Up @@ -688,6 +691,7 @@ impl RawRwLock {
}

// This is the same condition as try_lock_shared_fast
#[allow(clippy::collapsible_if)]
if *state & WRITER_BIT != 0 {
if !recursive || *state & READERS_MASK == 0 {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/remutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ mod tests {
use crate::ReentrantMutex;
use crate::ReentrantMutexGuard;
use std::cell::RefCell;
use std::sync::mpsc::channel;
use std::sync::Arc;
use std::thread;
use std::sync::mpsc::channel;

#[cfg(feature = "serde")]
use bincode::{deserialize, serialize};
Expand Down

0 comments on commit 3dcdfea

Please sign in to comment.