From b9c9bafccc94267f7702ca183a24435a09642de4 Mon Sep 17 00:00:00 2001 From: Arthur Silva Date: Thu, 19 Mar 2026 15:40:40 +0100 Subject: [PATCH] Rename `crossbeam` feature to `sharded-lock` The feature name `crossbeam` was misleading since it specifically enables `crossbeam_utils::sync::ShardedLock`, not the broader crossbeam ecosystem. Also added `stats` feature combinations to CI checks to restore coverage lost when replacing `--all-features`. --- .github/workflows/ci.yml | 4 ++-- Cargo.toml | 2 +- src/lib.rs | 12 ++++++------ src/rw_lock.rs | 16 ++++++++-------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d10aeeb..3a6a5e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: - run: cargo check --all-targets - run: cargo check --all-targets --features stats - run: cargo check --all-targets --no-default-features - - run: cargo check --all-targets --no-default-features --features crossbeam + - run: cargo check --all-targets --no-default-features --features sharded-lock - run: cargo check --all-targets --features shuttle test: @@ -44,7 +44,7 @@ jobs: override: true - run: cargo test - run: cargo test --no-default-features - - run: cargo test --no-default-features --features crossbeam + - run: cargo test --no-default-features --features sharded-lock # no run because of shuttle feature and non-shuttle tests - run: cargo test --features shuttle --no-run diff --git a/Cargo.toml b/Cargo.toml index 208fb2f..ad7960f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ rust-version = "1.71" [features] default = ["ahash", "parking_lot"] -crossbeam = ["dep:crossbeam-utils"] +sharded-lock = ["dep:crossbeam-utils"] shuttle = ["dep:shuttle"] stats = [] diff --git a/src/lib.rs b/src/lib.rs index e841eb7..7840608 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -66,25 +66,25 @@ //! # Synchronization primitives //! //! By default the crate uses [parking_lot](https://crates.io/crates/parking_lot), which is enabled (by default) via -//! a crate feature with the same name. If `parking_lot` is disabled and `crossbeam` is enabled, the crate uses +//! a crate feature with the same name. If `parking_lot` is disabled and `sharded-lock` is enabled, the crate uses //! [`crossbeam_utils::sync::ShardedLock`](https://docs.rs/crossbeam-utils/latest/crossbeam_utils/sync/struct.ShardedLock.html) //! from [crossbeam-utils](https://crates.io/crates/crossbeam-utils) instead. If both are disabled the crate defaults -//! to the std lib implementation. The `parking_lot` and `crossbeam` features are mutually exclusive. +//! to the std lib implementation. The `parking_lot` and `sharded-lock` features are mutually exclusive. //! //! # Cargo Features //! //! | Feature | Default | Description | //! |---------|---------|-------------| //! | `ahash` | ✓ | Use [ahash](https://crates.io/crates/ahash) as the default hasher. When disabled, falls back to std lib's `RandomState` (currently SipHash-1-3). | -//! | `parking_lot` | ✓ | Use [parking_lot](https://crates.io/crates/parking_lot) for synchronization primitives. Mutually exclusive with `crossbeam`. | -//! | `crossbeam` | | Use [`crossbeam_utils::sync::ShardedLock`](https://docs.rs/crossbeam-utils/latest/crossbeam_utils/sync/struct.ShardedLock.html) for synchronization primitives. Mutually exclusive with `parking_lot`. | +//! | `parking_lot` | ✓ | Use [parking_lot](https://crates.io/crates/parking_lot) for synchronization primitives. Mutually exclusive with `sharded-lock`. | +//! | `sharded-lock` | | Use [`crossbeam_utils::sync::ShardedLock`](https://docs.rs/crossbeam-utils/latest/crossbeam_utils/sync/struct.ShardedLock.html) for synchronization primitives. Mutually exclusive with `parking_lot`. | //! | `shuttle` | | Enable [shuttle](https://crates.io/crates/shuttle) testing support for concurrency testing. | //! | `stats` | | Enable cache statistics tracking via the `hits()` and `misses()` methods. | #![allow(clippy::type_complexity)] #![cfg_attr(docsrs, feature(doc_cfg))] -#[cfg(all(feature = "parking_lot", feature = "crossbeam"))] -compile_error!("features `parking_lot` and `crossbeam` are mutually exclusive"); +#[cfg(all(feature = "parking_lot", feature = "sharded-lock"))] +compile_error!("features `parking_lot` and `sharded-lock` are mutually exclusive"); #[cfg(not(fuzzing))] mod linked_slab; diff --git a/src/rw_lock.rs b/src/rw_lock.rs index 4bc6ecb..278f5b7 100644 --- a/src/rw_lock.rs +++ b/src/rw_lock.rs @@ -2,23 +2,23 @@ use std::ops::{Deref, DerefMut}; #[cfg(feature = "parking_lot")] type InnerRwLock = parking_lot::RwLock; -#[cfg(all(not(feature = "parking_lot"), feature = "crossbeam"))] +#[cfg(all(not(feature = "parking_lot"), feature = "sharded-lock"))] type InnerRwLock = crossbeam_utils::sync::ShardedLock; -#[cfg(all(not(feature = "parking_lot"), not(feature = "crossbeam")))] +#[cfg(all(not(feature = "parking_lot"), not(feature = "sharded-lock")))] type InnerRwLock = std::sync::RwLock; #[cfg(feature = "parking_lot")] type InnerRwLockReadGuard<'rwlock, T> = parking_lot::RwLockReadGuard<'rwlock, T>; -#[cfg(all(not(feature = "parking_lot"), feature = "crossbeam"))] +#[cfg(all(not(feature = "parking_lot"), feature = "sharded-lock"))] type InnerRwLockReadGuard<'rwlock, T> = crossbeam_utils::sync::ShardedLockReadGuard<'rwlock, T>; -#[cfg(all(not(feature = "parking_lot"), not(feature = "crossbeam")))] +#[cfg(all(not(feature = "parking_lot"), not(feature = "sharded-lock")))] type InnerRwLockReadGuard<'rwlock, T> = std::sync::RwLockReadGuard<'rwlock, T>; #[cfg(feature = "parking_lot")] type InnerRwLockWriteGuard<'rwlock, T> = parking_lot::RwLockWriteGuard<'rwlock, T>; -#[cfg(all(not(feature = "parking_lot"), feature = "crossbeam"))] +#[cfg(all(not(feature = "parking_lot"), feature = "sharded-lock"))] type InnerRwLockWriteGuard<'rwlock, T> = crossbeam_utils::sync::ShardedLockWriteGuard<'rwlock, T>; -#[cfg(all(not(feature = "parking_lot"), not(feature = "crossbeam")))] +#[cfg(all(not(feature = "parking_lot"), not(feature = "sharded-lock")))] type InnerRwLockWriteGuard<'rwlock, T> = std::sync::RwLockWriteGuard<'rwlock, T>; /// A reader-writer lock. @@ -58,7 +58,7 @@ pub struct RwLockReadGuard<'rwlock, T: ?Sized>(InnerRwLockReadGuard<'rwlock, T>) #[must_use = "if unused the RwLock will immediately unlock"] pub struct RwLockWriteGuard<'rwlock, T: ?Sized>(InnerRwLockWriteGuard<'rwlock, T>); -#[cfg(not(feature = "crossbeam"))] +#[cfg(not(feature = "sharded-lock"))] impl RwLock { /// Creates a new instance of an `RwLock` which is unlocked. pub const fn new(t: T) -> Self { @@ -66,7 +66,7 @@ impl RwLock { } } -#[cfg(feature = "crossbeam")] +#[cfg(feature = "sharded-lock")] impl RwLock { /// Creates a new instance of an `RwLock` which is unlocked. pub fn new(t: T) -> Self {