-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Mutex.withLock() added EXACTLY_ONCE contract #2010
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
Mutex.withLock() added EXACTLY_ONCE contract #2010
Conversation
Same issue on |
I think this needs to be |
I think that if |
Yep, I forgot that the compiler will assume anything run inside a |
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.
Looks good to me, but let's also add a similar contract on Semaphore.withPermit
in the same PR for consistency.
…lContracts to @OptIn(ExperimentalContracts::class)
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.
Good to go now. Waiting for tests to pass.
Kotlin#2010) Co-authored-by: zhouxin <[email protected]>
Mutex.withLock(owner: Any? = null, action: () -> T)
should be likesynchronized (lock: Any, block:()-> R)
, addEXACTLY_ONCE
contract.This is very helpful when the compiler infers variable initialization.