-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Support TATAS-like usage in islocked
and trylock
spec
#44820
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable. I think other users have transitioned to assert_havelock or other, more correct lock usages.
islocked
and trylock
islocked
and trylock
spec
tester_linux32 is not finished but it is hopefully OK since this PR mostly only updates the texts in the docstrings. The CI issue has been reported in #44859 and #ci-failure-help slack channel. |
This implements the `islocked`-`trylock` API documented in #44820 for `ReentrantLock` and `SpinLock`.
NOTICE: THIS IS NOT AN ENDORSEMENT OF SPIN LOCKS
Currently, how
islocked
should behave is not well-specified. This PR is an RFC for allowing usage like test-and-test-and-set lock or exponential backoff lock:Notably, this can be used for judging if a given implementation of
islocked
is correct for APIs like semaphore (#32299) and read-write lock where multiple tasks can enter the critical section in a certain way.From this point of view, the API could have been clearer if the name was
islockable
. But I think the predicateislocked
can also be interpreted as "am I locked out?" or "is it completely locked?"If we decide this API contract is a good direction, we need to fix
ReentrantLock
implementation (maybe in this PR or later).