简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM