Skip to content

Add a crossbeam sharded rwlock backend#110

Open
gz wants to merge 2 commits intoarthurprs:masterfrom
gz:sharded-rwlock
Open

Add a crossbeam sharded rwlock backend#110
gz wants to merge 2 commits intoarthurprs:masterfrom
gz:sharded-rwlock

Conversation

@gz
Copy link

@gz gz commented Mar 18, 2026

Use crossbeam-utils::sync::ShardedLock behind a new crossbeam feature when parking_lot is off.

Keep the existing wrapper API, document the feature, and fail fast when both lock backends are enabled.

Discussion in #108

Use crossbeam-utils::sync::ShardedLock behind a new crossbeam feature when parking_lot is off.

Keep the existing wrapper API, document the feature, and fail fast when both lock backends are enabled.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an optional crossbeam feature to use crossbeam_utils::sync::ShardedLock as the crate’s internal RwLock implementation when parking_lot is disabled.

Changes:

  • Introduce crossbeam Cargo feature and optional crossbeam-utils dependency.
  • Switch RwLock backend to ShardedLock under cfg(all(not(feature="parking_lot"), feature="crossbeam")).
  • Update crate docs and add a compile_error! guard for mutually exclusive parking_lot/crossbeam features.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/rw_lock.rs Adds crossbeam-based RwLock type aliases and adjusts RwLock::new const-ness under crossbeam.
src/lib.rs Documents the new backend selection and adds a mutual-exclusion compile-time check.
Cargo.toml Defines the crossbeam feature and adds crossbeam-utils as an optional dependency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@arthurprs arthurprs requested a review from Copilot March 18, 2026 22:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an alternative RwLock backend based on crossbeam_utils::sync::ShardedLock, selectable via a new crossbeam Cargo feature when parking_lot is disabled, while keeping the existing wrapper API and documenting the feature behavior.

Changes:

  • Add a crossbeam feature and optional crossbeam-utils dependency to support ShardedLock as the RwLock backend.
  • Document the new feature and add a compile-time error when parking_lot and crossbeam are both enabled.
  • Update CI to compile/test the new crossbeam configuration and avoid invalid --all-features runs.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/rw_lock.rs Adds ShardedLock as an alternate RwLock implementation behind the crossbeam feature.
src/lib.rs Documents the new backend selection and enforces mutual exclusivity via compile_error!.
Cargo.toml Introduces the crossbeam feature and optional crossbeam-utils dependency.
.github/workflows/ci.yml Adjusts CI commands to cover the new feature without using --all-features.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants