Skip to content
Advertisement

using the Hazelcast distributed locks with Coroutines in Kotlin and Spring webflux

My question is as the documentation says, fencedlocks are reentrant locks for “THREADS” and I am using spring boot with Kotlin and webflux so in my application I am using Coroutines for concurrency and as you probably know spring webflux provides an event-loop with a limited number of threads to fulfilling the Coroutines, what will happen if I use this lock with coroutines? based on my understanding because this lock is reentrant and the number of threads is limited so there is a chance that when you lock a block with it another coroutine could enter that block with the same under-the-hood thread.

My use case is locking a block of code with a userId in my application.

https://docs.hazelcast.com/imdg/4.2/data-structures/fencedlock

Advertisement

Answer

the lock can be re-acquired by the same thread, this is possible. But you can disable or manage reentrancy behavior with FencedLockConfig

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement