Skip to content

rust: simplify lock guards by using marker types#628

Merged
wedsonaf merged 1 commit intoRust-for-Linux:rustfrom
wedsonaf:guard-marker
Jan 18, 2022
Merged

rust: simplify lock guards by using marker types#628
wedsonaf merged 1 commit intoRust-for-Linux:rustfrom
wedsonaf:guard-marker

Conversation

@wedsonaf
Copy link
Copy Markdown

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 wedsonaf@google.com

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 <wedsonaf@google.com>
@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