arrow-fx-stm / arrow.fx.stm / STM / size

size

open fun <A> TQueue<A>.size(): Int

Return the current number of elements in a TQueue

import arrow.fx.stm.TQueue
import arrow.fx.stm.atomically

suspend fun main() {
  //sampleStart
  val tq = TQueue.new<Int>()
  val result = atomically {
    tq.size()
  }
  //sampleEnd
  println("Result $result")
}

This function never retries.

This function has to access both TVar’s and thus may lead to increased contention, use sparingly.

Do you like Arrow?

Arrow Org
<