https://kotlinlang.org logo
Title
m

mp

04/01/2022, 9:38 AM
hi there guys I`m working on code that should call from lock context suspend functions
kotlin.concurrent

@kotlin.internal.InlineOnly
public inline fun <T> Lock.withLock(action: () -> T): T {
    contract { callsInPlace(action, InvocationKind.EXACTLY_ONCE) }
    lock()
    try {
        return action()
    } finally {
        unlock()
    }
}
but it says
The 'checkRegistry' suspension point is inside a critical section
Newbee with corutines\suspend so - can anyone share document reference that will help me to understand what I’ve miss
s

Sam

04/01/2022, 9:41 AM
Lock
is designed for use with blocking code running in threads. If you absolutely need to use locks with coroutines you should use Mutex instead.
m

mp

04/01/2022, 9:44 AM
indeed but (miss to describe) project using hazlecast - thats make things a bit tricky @Sam tnx - will check