withLock

expect inline fun <T> ReentrantLock.withLock(block: () -> T): T

Executes the given block of code while holding the specified ReentrantLock. This function simplifies the process of acquiring and releasing a lock safely.

Usage:

val lock = reentrantLock()
lock.withLock {
// Critical section of code
}
actual inline fun <T> ReentrantLock.withLock(block: () -> T): T

Executes the given block of code while holding the specified ReentrantLock. This function simplifies the process of acquiring and releasing a lock safely.

Usage:

val lock = reentrantLock()
lock.withLock {
// Critical section of code
}