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

Add into_mutex_reference for MutexGuard #3741

Closed
wants to merge 1 commit into from

Conversation

kaimast
Copy link

@kaimast kaimast commented May 3, 2021

Motivation

In order to build a condition variable (#2739) in tokio there needs to be a way to release the lock and get a reference to the underlying Mutex.

One way to do this would be to pass both the MutexGuard and a reference to the Mutex to Condvar::wait but that would differ from the API in std:sync.

Solution

This pull request adds a single function MutexGuard::into_mutex_reference (suggestions for a better name are welcome). The method consumes the MutexGuard object, releases the underlying lock and returns a reference to the Mutex.

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-sync Module: tokio/sync labels May 3, 2021
@kaimast
Copy link
Author

kaimast commented May 3, 2021

Going to close this for now. See the changes to #3742 that makes this pull request unnecessary.

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.

2 participants