Skip to content
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

Make RwLockReadGuard covariant #45

Merged
merged 4 commits into from
May 27, 2023

Conversation

Jules-Bertholet
Copy link
Collaborator

And refactor RwLock implementation into non-generic core and generic interface, which should reduce binary sizes.

Fixes #9

Copy link
Member

@notgull notgull left a comment

Choose a reason for hiding this comment

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

I would rather if you split some of this code into a new module. The rwlock.rs file is getting too big as it is; it would be nice to split it off into a separate file.

I'd also appreciate it if you split the RawRwLock code and the covariance code into two separate commits. It would make it easier to review. See this for a guide.

It would also be nice to add a test (i.e. use function bounds to make sure it's actually covariant) and to resolve the merge conflict.

And refactor `RwLock` implementation into
non-generic core and generic interface
@Jules-Bertholet
Copy link
Collaborator Author

I would rather if you split some of this code into a new module.

It would also be nice to add a test (i.e. use function bounds to make sure it's actually covariant) and to resolve the merge conflict.

Done.

I'd also appreciate it if you split the RawRwLock code and the covariance code into two separate commits.

Unfortunately this isn't really possible. RawRwLock is necessary for covariance, and once you have the former, the latter is a question of changing one field type from *mut T to *const T. If there was a way of meaningfully splitting these up, I would have submitted two PRs.

src/mutex.rs Show resolved Hide resolved
src/rwlock.rs Outdated Show resolved Hide resolved
src/rwlock.rs Show resolved Hide resolved
src/rwlock.rs Show resolved Hide resolved
src/rwlock.rs Show resolved Hide resolved
src/rwlock.rs Show resolved Hide resolved
src/rwlock.rs Show resolved Hide resolved
src/rwlock/raw.rs Show resolved Hide resolved
src/rwlock/raw.rs Outdated Show resolved Hide resolved
src/rwlock/raw.rs Show resolved Hide resolved
Copy link
Member

@notgull notgull left a comment

Choose a reason for hiding this comment

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

Thanks! Looks good to me aside from the minor typo.

src/mutex.rs Outdated Show resolved Hide resolved
@notgull notgull merged commit 0b71083 into smol-rs:master May 27, 2023
8 checks passed
@Jules-Bertholet Jules-Bertholet deleted the covariant-rwlock-read branch May 27, 2023 04:37
@notgull
Copy link
Member

notgull commented May 27, 2023

@Jules-Bertholet Are you planning on making any other changes? If not I'd like to push this along with #42 as a new version.

@Jules-Bertholet
Copy link
Collaborator Author

I was planning on making a PR for owned Arc guards...

@notgull notgull mentioned this pull request Aug 10, 2023
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.

Make RwLockReadGuard covariant over its type parameter
2 participants