arrow-fx-coroutines / arrow.fx.coroutines / Semaphore / tryAcquireN
abstract suspend fun tryAcquireN(n:
Long
):
Boolean
Acquires n permits and signals success with a Boolean immediately.
import arrow.fx.coroutines.*
suspend fun main(): Unit {
//sampleStart
val semaphore = Semaphore(5)
val failed = semaphore.tryAcquireN(6)
val succeed = semaphore.tryAcquireN(5)
//sampleEnd
println("failed: $failed, succeed: $succeed")
}
n
- number of permits to acquire; must be greater or equal than zero.
Do you like Arrow?
✖