-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Tracking Issue for ReentrantLock
#121440
Comments
I'll put in my vote for
|
I'm still dreaming of a future in which we have a poison-free |
I don't see why "Mutex" would implicitly mean "poisoned". That's not an obvious naming scheme at all. |
If we have unpoisoned mutexes in the future, it'd probably be better to do something like |
Alright question, why not have interior mutability on the ReentrantLock? I don't think there's a data race problem here, but I might be missing something |
You mean returning an Then I could acquire the lock twice in the same thread, have two aliasing mutable references, and proceed to break everything from there. |
Good catch, I didn’t notice why everything blows up with this, just noticed how interior mutability was out of the question and wondered why |
Please make try_lock be public to be the same as Mutex and RwLock. |
It is the sort of lock you throw away the key to. Perhaps |
#125527 corrects the Sync impl to be something actually suitable for a publicly usable type. |
…ubilee Add manual Sync impl for ReentrantLockGuard Fixes: rust-lang#125526 Tracking Issue: rust-lang#121440 this impl is even shown in the summary in the tracking issue, but apparently was forgotten in the actual implementation
…ubilee Add manual Sync impl for ReentrantLockGuard Fixes: rust-lang#125526 Tracking Issue: rust-lang#121440 this impl is even shown in the summary in the tracking issue, but apparently was forgotten in the actual implementation
…ubilee Add manual Sync impl for ReentrantLockGuard Fixes: rust-lang#125526 Tracking Issue: rust-lang#121440 this impl is even shown in the summary in the tracking issue, but apparently was forgotten in the actual implementation
Rollup merge of rust-lang#125527 - programmerjake:patch-2, r=workingjubilee Add manual Sync impl for ReentrantLockGuard Fixes: rust-lang#125526 Tracking Issue: rust-lang#121440 this impl is even shown in the summary in the tracking issue, but apparently was forgotten in the actual implementation
Feature gate:
#![feature(reentrant_lock)]
This is a tracking issue for
ReentrantLock
, a re-entrant lock useful for avoiding a common type of deadlocks.Public API
Steps / History
sync::ReentrantLock
libs-team#193ReentrantLock
public #110543Unresolved Questions
Poisoning
I would argue that
ReentrantLock
should not implement lock poisoning. Since it only provides shared access, breaking the invariants of the inner type is something that the lock has no control over, as it requires interior mutability. It would make sense to require thatT: RefUnwindSafe
, but I think that is too inconvenient for now. IfRefUnwindSafe
were a lint trait, it should definitely be used.Fallible locking
Is there a need for fallible locking, even if it cannot fail because of reentrancy? How would this look like, considering that
TryLockResult
also has a poisoning case, which would never be used here?Naming
New synchronization primitives like
OnceLock
have used theLock
suffix. IMHO the nameReentrantLock
rhymes well with the other types and is more consistent, butReentrantMutex
better highlights the similarity toMutex
.Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩
The text was updated successfully, but these errors were encountered: