arrow-fx-stm / arrow.fx.stm / STM / available

available

open fun TSemaphore.available(): Int

Returns the currently available number of permits in a TSemaphore.

import arrow.fx.stm.TSemaphore
import arrow.fx.stm.atomically

suspend fun main() {
  //sampleStart
  val tsem = TSemaphore.new(5)
  val result = atomically {
    tsem.available()
  }
  //sampleEnd
  println("Result $result")
  println("Permits remaining ${atomically { tsem.available() }}")
}

This function never retries.

Do you like Arrow?

Arrow Org
<