https://kotlinlang.org logo
#coroutines
Title
# coroutines
r

Robert

02/09/2020, 3:11 PM
Is having a reentrant readwrite lock an anitpattern in a reactive stack? Does it make sense to wrap it into a coroutines?
a

altavir

02/10/2020, 5:02 AM
There is no reentrant lock in coroutines right now. You should probably follow semaphore development.
r

Robert

02/10/2020, 7:22 AM
I mean I’ve a component that contains a read/write lock and get’s called by a suspended function
a

altavir

02/10/2020, 7:24 AM
Java reentrant lock is blocking. If you are using blocking io, you can use it, but you won't get benifits from coroutines. You should remember to use
<http://Dispatchers.IO|Dispatchers.IO>
though not to block the pool. If you are using NIO, you should try to rewrite your code to avoid the lock entirely, or use coroutines Mutex.
r

Robert

02/10/2020, 1:25 PM
Good input, will look into that
5 Views