-
Notifications
You must be signed in to change notification settings - Fork 225
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
Expose more methods from mapped guards #444
Comments
Yes, I would I accept a PR for these. Fundamentally these are unsafe functions so it's fine to expose them with appropriate warnings. |
I also came across a situation where I needed to downgrade a write mapped guard to a read mapped guard. So there are a few APIs missing. |
@Amanieu is there any fundamental reason why a mapped guard can't have It's maybe slightly weird since you'd actually be unlocking the parent object, not the mapped result, but that's what I want to do. Open to workarounds too. |
That's fundamentally unsound because while the mutex is a unlocked, another thread can lock it and then invalidate the mapping. For example, if the mutex contains an enum which has been mapped to one variant, another thread can lock the mutex and switch the enum to the other variant. |
@Amanieu would it be sound if (obviously you probably don't want to do this for many reasons, just curious for my own education on soundness here) |
Yes that would be sound, but then you would lose the type erasure since |
That makes sense If anyone is googling this and trying to do the same thing, I worked around this by making a trait like |
While very useful, mapped guards do not currently expose methods such as
raw
andforce_unlock
, which makes using them in certain contexts quite difficult. From what I can tell, there's no soundness reason why they haven't been exposed. Would a PR adding the same APIs to them as the other guards be accepted?The text was updated successfully, but these errors were encountered: