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

Condvar variant usable with ReentrantMutex #452

Open
gdesmott opened this issue Nov 25, 2024 · 1 comment
Open

Condvar variant usable with ReentrantMutex #452

gdesmott opened this issue Nov 25, 2024 · 1 comment

Comments

@gdesmott
Copy link

Condvar is not usable with ReentrantMutex because of Condvar::wait() takes a MutexGuard.

Any reason to not have a variant of the API handling ReentrantMutex ?

@bjorn3
Copy link
Contributor

bjorn3 commented Nov 25, 2024

Condvar::wait() has to unlock the mutex. For a reentrant mutex it would have to unlock all mutex guards for the mutex to prevent a deadlock. This would be unsound however as ReentrantMutexGuard is Sync and thus another thread may be accessing a ReentrantMutexGuard while it is unlocked if Condvar::wait() were to unlock all mutex guards rather than just the one that is passed in.

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

No branches or pull requests

2 participants