Skip to content

rust: simplify lock guards by using marker types #628

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

Merged
merged 1 commit into from
Jan 18, 2022

Conversation

wedsonaf
Copy link

Unify Guard and GuardMut into a single type parametrised by a
marker. The new guard implementation is the same as the existing Guard
except that if the marker is WriteLock, it also implements DerefMut
(which was only implemented by GuardMut previously).

This is in preparation for adding abstractions for read/write locks,
which means that a single lock primitive needs to implement the Lock
primitive in both shared and mutable modes, which is enabled by this
change as well.

Signed-off-by: Wedson Almeida Filho [email protected]

Unify `Guard` and `GuardMut` into a single type parametrised by a
marker. The new guard implementation is the same as the existing `Guard`
except that if the marker is `WriteLock`, it also implements `DerefMut`
(which was only implemented by `GuardMut` previously).

This is in preparation for adding abstractions for read/write locks,
which means that a single lock primitive needs to implement the `Lock`
primitive in both shared and mutable modes, which is enabled by this
change as well.

Signed-off-by: Wedson Almeida Filho <[email protected]>
@wedsonaf wedsonaf merged commit d37432d into Rust-for-Linux:rust Jan 18, 2022
@wedsonaf wedsonaf deleted the guard-marker branch January 18, 2022 17:07
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.

1 participant