Skip to content

try_upgrade for rwlock #7284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

nevakrien
Copy link

the code is a rough draft and is mostly here to help the discussion in #7282

Motivation

in #7282 there was an idea to add an upgrade method to write locks.
I hope to achieve this without changing any existing code as it is a small feature

Solution

the key idea is that we can use compare_exchange to try and fish for specifically the situation where we have 1 reader and exchange the semiphore to 1 writer. this should be safe because of the invariant of compare_exchange

@github-actions github-actions bot added the R-loom-sync Run loom sync tests on this PR label Apr 23, 2025
@nevakrien nevakrien changed the title added initial sketch try_upgrade for rwlock Apr 23, 2025
@Darksonn Darksonn added A-tokio Area: The main tokio crate M-sync Module: tokio/sync labels Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-sync Module: tokio/sync R-loom-sync Run loom sync tests on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants