-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Explicit unlock for locks #7500
Comments
I think the main problem will be detecting which local variables are guards of this kind. Should it go based on:
How can a project specify the names usually involved with this kind of code? |
If this is to be done, I would avoid guessing via heuristics. I would instead allow marking guard-like types explicitly with a custom attribute or similar. |
Agreed. We can just include std types like There is a questionable case here - what if Perhaps it would be simpler to just always require |
If user found it doesn't make sense to add a block around entire function, they have the choice of using
It shouldn't be. Locks can come at beginning of functions and loops and ifs accidentally. But if a lock appears in a simple unnecessary block, we can almost be sure that propose of that block is to explicitly declare the scope of guard.
Maybe. I have no idea of implementation. But as a user I prefer block (in addition to drop) because it is visually cleaner. |
What it does
Force locks to have a dedicated block which lock is acquired at first line of it, or an explicit
drop
.Categories
Why?
Implicit drops can be surprising and some users of linux community forum lwn have some concerns about it that can cause bug in linux kernel. It can also encourage people to free locks sooner.
Drawbacks
None.
Example
Could be written as:
Or with drop:
The text was updated successfully, but these errors were encountered: