writeFront
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() }}")
}
Content copied to clipboard
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.