arrow-fx / arrow.fx / Semaphore / available
abstract fun available(): Kind<F,
Long
>
Get a snapshot of the currently available permits, always non negative.
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.available()
}
//sampleEnd
println(result)
}
Do you like Arrow?
✖