Skip to content

Conversation

@SabrinaJewson
Copy link
Contributor

I did not add mapping functions as it's not possible to implement them soundly without adding another generic parameter to the guards, which I will leave to another PR. I implemented OwnedRwLockWriteGuard::downgrade as a method because RwLockWriteGuard::downgrade is a method - but that was probably a mistake, so I'm not sure.

Fixes: #3327

Motivation

The feature is already present for mutexes, and it is useful in some scenarios with RwLocks.

Solution

Add OwnedRwLockReadGuard and OwnedRwLockWriteGuard, which are variants of RwLockReadGuard and RwLockWriteGuard that store an Arc.

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-sync Module: tokio/sync labels Dec 25, 2020
@Darksonn
Copy link
Contributor

Please update your PR to have separate RwLockWriteGuard and RwLockMappedWriteGuard types as discussed in #3344, #3345 and #3348. Also note the reorganization in #3348, which will likely be merged first, and which you may want to wait for.

@SabrinaJewson
Copy link
Contributor Author

I've rebased on #3348 now.

I did not add mapping functions as it's not possible to implement them
soundly without adding another generic parameter to the guards, which I
will leave to another PR.

Fixes: tokio-rs#3327
@SabrinaJewson
Copy link
Contributor Author

After another rebase, it should finally be good to review now. I didn't choose the best of times to make this PR 😅.

Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

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

Hey, sorry for the delay in reviewing. I don't have any comments besides the one below.

Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

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

This seems ok to me.

@Darksonn Darksonn merged commit 0dc4769 into tokio-rs:master Mar 23, 2021
@Darksonn Darksonn mentioned this pull request Apr 12, 2021
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add OwnedRwLockReadGuard + OwnedRwLockWriteGuard

2 participants