Skip to content

Commit 84bc222

Browse files
authored
Rename crossbeam feature to sharded-lock (#111)
The feature name `crossbeam` was misleading since it specifically enables `crossbeam_utils::sync::ShardedLock`, not the broader crossbeam ecosystem.
1 parent 752b3b4 commit 84bc222

4 files changed

Lines changed: 17 additions & 17 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- run: cargo check --all-targets
2727
- run: cargo check --all-targets --features stats
2828
- run: cargo check --all-targets --no-default-features
29-
- run: cargo check --all-targets --no-default-features --features crossbeam
29+
- run: cargo check --all-targets --no-default-features --features sharded-lock
3030
- run: cargo check --all-targets --features shuttle
3131

3232
test:
@@ -44,7 +44,7 @@ jobs:
4444
override: true
4545
- run: cargo test
4646
- run: cargo test --no-default-features
47-
- run: cargo test --no-default-features --features crossbeam
47+
- run: cargo test --no-default-features --features sharded-lock
4848
# no run because of shuttle feature and non-shuttle tests
4949
- run: cargo test --features shuttle --no-run
5050

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ rust-version = "1.71"
1414

1515
[features]
1616
default = ["ahash", "parking_lot"]
17-
crossbeam = ["dep:crossbeam-utils"]
17+
sharded-lock = ["dep:crossbeam-utils"]
1818
shuttle = ["dep:shuttle"]
1919
stats = []
2020

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,25 +66,25 @@
6666
//! # Synchronization primitives
6767
//!
6868
//! By default the crate uses [parking_lot](https://crates.io/crates/parking_lot), which is enabled (by default) via
69-
//! a crate feature with the same name. If `parking_lot` is disabled and `crossbeam` is enabled, the crate uses
69+
//! a crate feature with the same name. If `parking_lot` is disabled and `sharded-lock` is enabled, the crate uses
7070
//! [`crossbeam_utils::sync::ShardedLock`](https://docs.rs/crossbeam-utils/latest/crossbeam_utils/sync/struct.ShardedLock.html)
7171
//! from [crossbeam-utils](https://crates.io/crates/crossbeam-utils) instead. If both are disabled the crate defaults
72-
//! to the std lib implementation. The `parking_lot` and `crossbeam` features are mutually exclusive.
72+
//! to the std lib implementation. The `parking_lot` and `sharded-lock` features are mutually exclusive.
7373
//!
7474
//! # Cargo Features
7575
//!
7676
//! | Feature | Default | Description |
7777
//! |---------|---------|-------------|
7878
//! | `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). |
79-
//! | `parking_lot` | ✓ | Use [parking_lot](https://crates.io/crates/parking_lot) for synchronization primitives. Mutually exclusive with `crossbeam`. |
80-
//! | `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`. |
79+
//! | `parking_lot` | ✓ | Use [parking_lot](https://crates.io/crates/parking_lot) for synchronization primitives. Mutually exclusive with `sharded-lock`. |
80+
//! | `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`. |
8181
//! | `shuttle` | | Enable [shuttle](https://crates.io/crates/shuttle) testing support for concurrency testing. |
8282
//! | `stats` | | Enable cache statistics tracking via the `hits()` and `misses()` methods. |
8383
#![allow(clippy::type_complexity)]
8484
#![cfg_attr(docsrs, feature(doc_cfg))]
8585

86-
#[cfg(all(feature = "parking_lot", feature = "crossbeam"))]
87-
compile_error!("features `parking_lot` and `crossbeam` are mutually exclusive");
86+
#[cfg(all(feature = "parking_lot", feature = "sharded-lock"))]
87+
compile_error!("features `parking_lot` and `sharded-lock` are mutually exclusive");
8888

8989
#[cfg(not(fuzzing))]
9090
mod linked_slab;

src/rw_lock.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ use std::ops::{Deref, DerefMut};
22

33
#[cfg(feature = "parking_lot")]
44
type InnerRwLock<T> = parking_lot::RwLock<T>;
5-
#[cfg(all(not(feature = "parking_lot"), feature = "crossbeam"))]
5+
#[cfg(all(not(feature = "parking_lot"), feature = "sharded-lock"))]
66
type InnerRwLock<T> = crossbeam_utils::sync::ShardedLock<T>;
7-
#[cfg(all(not(feature = "parking_lot"), not(feature = "crossbeam")))]
7+
#[cfg(all(not(feature = "parking_lot"), not(feature = "sharded-lock")))]
88
type InnerRwLock<T> = std::sync::RwLock<T>;
99

1010
#[cfg(feature = "parking_lot")]
1111
type InnerRwLockReadGuard<'rwlock, T> = parking_lot::RwLockReadGuard<'rwlock, T>;
12-
#[cfg(all(not(feature = "parking_lot"), feature = "crossbeam"))]
12+
#[cfg(all(not(feature = "parking_lot"), feature = "sharded-lock"))]
1313
type InnerRwLockReadGuard<'rwlock, T> = crossbeam_utils::sync::ShardedLockReadGuard<'rwlock, T>;
14-
#[cfg(all(not(feature = "parking_lot"), not(feature = "crossbeam")))]
14+
#[cfg(all(not(feature = "parking_lot"), not(feature = "sharded-lock")))]
1515
type InnerRwLockReadGuard<'rwlock, T> = std::sync::RwLockReadGuard<'rwlock, T>;
1616

1717
#[cfg(feature = "parking_lot")]
1818
type InnerRwLockWriteGuard<'rwlock, T> = parking_lot::RwLockWriteGuard<'rwlock, T>;
19-
#[cfg(all(not(feature = "parking_lot"), feature = "crossbeam"))]
19+
#[cfg(all(not(feature = "parking_lot"), feature = "sharded-lock"))]
2020
type InnerRwLockWriteGuard<'rwlock, T> = crossbeam_utils::sync::ShardedLockWriteGuard<'rwlock, T>;
21-
#[cfg(all(not(feature = "parking_lot"), not(feature = "crossbeam")))]
21+
#[cfg(all(not(feature = "parking_lot"), not(feature = "sharded-lock")))]
2222
type InnerRwLockWriteGuard<'rwlock, T> = std::sync::RwLockWriteGuard<'rwlock, T>;
2323

2424
/// A reader-writer lock.
@@ -58,15 +58,15 @@ pub struct RwLockReadGuard<'rwlock, T: ?Sized>(InnerRwLockReadGuard<'rwlock, T>)
5858
#[must_use = "if unused the RwLock will immediately unlock"]
5959
pub struct RwLockWriteGuard<'rwlock, T: ?Sized>(InnerRwLockWriteGuard<'rwlock, T>);
6060

61-
#[cfg(not(feature = "crossbeam"))]
61+
#[cfg(not(feature = "sharded-lock"))]
6262
impl<T> RwLock<T> {
6363
/// Creates a new instance of an `RwLock<T>` which is unlocked.
6464
pub const fn new(t: T) -> Self {
6565
Self(InnerRwLock::new(t))
6666
}
6767
}
6868

69-
#[cfg(feature = "crossbeam")]
69+
#[cfg(feature = "sharded-lock")]
7070
impl<T> RwLock<T> {
7171
/// Creates a new instance of an `RwLock<T>` which is unlocked.
7272
pub fn new(t: T) -> Self {

0 commit comments

Comments
 (0)