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

Adds guarded ref and mut access for UnsafeCell #116

Closed
wants to merge 2 commits into from

Conversation

kylefleming
Copy link

This PR adds methods guard_ref_access and guard_mut_access to UnsafeCell as an alternative to with and with_mut for tracking read and write access to the underlying cell data.

The 2 methods return tokens (UnsafeCellRefToken and UnsafeCellMutToken, respectively) that implement Drop so that the beginning of the access can be marked by the invocation of the guard_*_access methods and the end of the access is marked by the release of the token object.

I appologize in advance for the lack of proper documentation and tests to accompany the feature. However, I did add doc comments.

This PR also allows the T parameter of UnsafeCell<T> to be unsized (T: ?Sized) to mirror std::cell::UnsafeCell, although I can break that out into a separate PR if needed.

@hawkw hawkw closed this in b70695a Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant