arrow-fx-coroutines / arrow.fx.coroutines / Semaphore / count

count

abstract suspend fun count(): Long

Gets a snapshot of the number of permits callers are waiting for, when there are no permits available.

The count is current available permits minus the outstanding acquires.

import arrow.fx.coroutines.*

suspend fun main(): Unit {
  //sampleStart
  val semaphore = Semaphore(5)
  val count = semaphore.count()
  //sampleEnd
  println("$count: count")
}

Do you like Arrow?

Arrow Org
<