writeFront

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() {
//sampleStart
val tq = TQueue.new<Int>()
atomically {
tq.write(1)
tq.writeFront(2)
}
//sampleEnd
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.