more ios/macos targets implementation
This commit is contained in:
1 parent
87a0c14b85
commit
fa87a0f611
19 files changed
+475
-30
No files matched your search
@@ -0,0 +1,27 @@
|
||||
package net.sergeych.synctools
|
||||
|
||||
import kotlinx.atomicfu.locks.ReentrantLock
|
||||
|
||||
/**
|
||||
* Get the platform-depended implementation of a mutex. It does nothing in the
|
||||
* browser and use appropriate mechanics on JVM and native targets. See
|
||||
* [ProtectedOpImplementation.invoke], [ProtectedOpImplementation.withLock]
|
||||
* ```kotlin
|
||||
* val op = ProtectedOp()
|
||||
* //...
|
||||
* op {
|
||||
* // mutually exclusive execution
|
||||
* println("sequential execution here")
|
||||
* }
|
||||
* ~~~
|
||||
*/
|
||||
actual fun ProtectedOp(): ProtectedOpImplementation = object : ProtectedOpImplementation {
|
||||
private val access = ReentrantLock()
|
||||
override fun lock() {
|
||||
access.lock()
|
||||
}
|
||||
|
||||
override fun unlock() {
|
||||
access.unlock()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user