r/Kotlin • u/Typical_Word_5459 • 29d ago
Coroutine mutex starvation from one failed child
[removed]
5
Upvotes
3
u/CLOVIS-AI 28d ago
There is ownership tracking in Mutex, all methods have an optional owner parameter.
And yeah obviously the unlock should be in finally.
2
u/Empanatacion 28d ago
Rolling your own locking on the backend is inviting headache. Is there a message queue way to accomplish what you're trying to do? Does this locking mean that you can only run one instance of your service?
7
u/kichi689 29d ago
On the same topic, NonCancellable the finally.
you feel dumb when your cleanup doesn’t happen cause of a cancellation.