Hi.. I want to use mutex.withLock{...} but it requ...
# coroutines
w
Hi.. I want to use mutex.withLock{...} but it requires ‘suspend’ keyword which is a breaking change, how can I achieve the same effect (like synchronized in java) without leaking/changing my fun def? (KMP btw)
r
wrap with
runBlocking
maybe?
w
runBlocking in undefined in commonMain (KMP)
r
do you support JS?
w
yes I do, but it’s just there because I can :D
r
I guess you need to either change your API or implement a
runblocking
equivalent for JS. But I’m a Kotlin newbie, so if there’s a different solution I’d love to know as well 🙂
w
Thanks for you input, if I find anything else i’ll let you know :D
👍 1
Ok so I found a solution, I used SynchronizedObject/ReentrantLock from kotlinx.atomicfu library :D
😃 1