Is there a way to suspend until a mutex is unlocke...
# coroutines
l
Is there a way to suspend until a mutex is unlocked, but without locking it? I.e. there's some kind of operation that "locks" the mutex, and only it can run. But there's another, "friendly" kind of operation that can run concurrently with other "friendly" operations, but not when the mutex is locked. That also means a locking operation will have to suspend until all "friendly" operations finish.
k
What you're looking for I think is a readers writers lock. https://en.m.wikipedia.org/wiki/Readers%E2%80%93writer_locklock Kotlinx coroutines does not currently have support for this out of the box. I suggest you chime in here: https://github.com/Kotlin/kotlinx.coroutines/issues/94
l
Ayup, found the issue, thanks.
Am currently working on implementing my own, I think...
My own implementation of the Read-Write Mutex proved a bit too hard and time-expensive. Actors are only available on the JVM, as they're considered obsolete because of complex actors, that aren't implemented yet. What alternative do I have, besides using a single mutex for both read and write?