common open fun <A> TQueue<A>.writeFront(a: A)

Prepend an element to the TQueue.

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

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

Mainly used to implement TQueue.peek and since this writes to the read variable of a TQueue excessive use can lead to contention on consumers. Prefer appending to a TQueue if possible.

This function never retries.

Do you like Arrow?

Arrow Org