Skip to content

Add value accessor methods to Mutex and RwLock#133406

Merged
bors merged 1 commit into
rust-lang:masterfrom
EFanZh:lock-value-accessors
Dec 15, 2024
Merged

Add value accessor methods to Mutex and RwLock#133406
bors merged 1 commit into
rust-lang:masterfrom
EFanZh:lock-value-accessors

Conversation

@EFanZh

@EFanZh EFanZh commented Nov 24, 2024

Copy link
Copy Markdown
Contributor

This PR adds get, set and replace methods to the Mutex and RwLock types for quick access to their contained values.

One possible optimization would be to check for poisoning first and return an error immediately, without attempting to acquire the lock. I didn’t implement this because I consider poisoning to be relatively rare, adding this extra check could slow down common use cases.

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

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants