Skip to content

utils: Fix ShardedLock::write documentation copied from read#1292

Open
teddytennant wants to merge 1 commit into
crossbeam-rs:mainfrom
teddytennant:sharded-lock-write-doc
Open

utils: Fix ShardedLock::write documentation copied from read#1292
teddytennant wants to merge 1 commit into
crossbeam-rs:mainfrom
teddytennant:sharded-lock-write-doc

Conversation

@teddytennant

Copy link
Copy Markdown
Contributor

What

Rewords the blocking-behavior paragraph in ShardedLock::write's doc comment, which was copied verbatim from read and describes the wrong semantics.

Why

The current text says write blocks "until there are no more writers which hold the lock" and that "there may be other readers currently inside the lock when this method returns". Both statements are true for read but wrong for write: it acquires every shard exclusively, so it also blocks while readers hold the lock, and no readers can be inside once it returns — the method's own example demonstrates this with try_read failing while the write guard is held. The new wording matches std::sync::RwLock::write, keeping the existing sentence about no ordering guarantees between contentious readers and writers.

Testing

Doc-only, no behavior change.

  • cargo test --test sharded_lock in crossbeam-utils — 15 passed
  • cargo test --doc sharded_lock — 9 passed
  • rustfmt --check — clean

The paragraph was copied verbatim from ShardedLock::read: it claimed
write blocks only until there are no more writers and that other
readers may be inside the lock when it returns. write acquires every
shard exclusively, so it blocks while any readers or writers hold the
lock, and no readers can be inside once it returns (as the method's
own example demonstrates with try_read failing). Reword to match
std::sync::RwLock::write.
Copilot AI review requested due to automatic review settings July 11, 2026 17:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants