arrow-fx / arrow.fx / Semaphore / count
abstract fun count(): Kind<F,
Long
>
Get a snapshot of the current count, may be negative. The count is current available permits minus the outstanding acquires.
import arrow.fx.*
import arrow.fx.extensions.io.async.async
import arrow.fx.extensions.io.monad.flatMap
fun main(args: Array<String>) {
//sampleStart
val semaphore = Semaphore.uncancellable<ForIO>(5, IO.async())
val result = semaphore.flatMap { s ->
s.count()
}
//sampleEnd
println(result)
}
Do you like Arrow?
✖