Skip to content

try_upgrade for rwlock#7284

Closed
nevakrien wants to merge 1 commit intotokio-rs:masterfrom
nevakrien:try_upgrade
Closed

try_upgrade for rwlock#7284
nevakrien wants to merge 1 commit intotokio-rs:masterfrom
nevakrien:try_upgrade

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
@Darksonn Darksonn closed this Jun 8, 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