common open fun <A> TQueue<A>.tryPeek(): A?

Same as TQueue.peek except it returns null if the TQueue is empty.

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

suspend fun main() {
  val tq = TQueue.new<Int>()
  val result = atomically {
  println("Result $result")
  println("Items in queue ${atomically { tq.flush() }}")

This function never retries.

See also


arrow.fx.stm.STM for a version that retries if the TQueue is empty.

Do you like Arrow?

Arrow Org