forked from sergeych/crypto2
13 lines
370 B
Kotlin
13 lines
370 B
Kotlin
package net.sergeych.tools
|
|
|
|
import kotlinx.atomicfu.locks.SynchronizedObject
|
|
import kotlinx.atomicfu.locks.synchronized
|
|
|
|
actual fun ProtectedOp(): ProtectedOpImplementation = object : ProtectedOpImplementation {
|
|
private val lock = SynchronizedObject()
|
|
override fun <T> invoke(f: () -> T): T {
|
|
synchronized(lock) {
|
|
return f()
|
|
}
|
|
}
|
|
} |