//arrow-fx-stm/arrow.fx.stm/STM/flush

flush

common open fun <A> TQueue<A>.flush(): List<A>

Drains all entries of a TQueue into a single list.

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

suspend fun main() {
  //sampleStart
  val tq = TQueue.new<Int>()
  val result = atomically {
    tq.write(2)
    tq.write(4)

    tq.flush()
  }
  //sampleEnd
  println("Result $result")
  println("Items in queue ${atomically { tq.flush() }}")
}

This function never retries.

Do you like Arrow?

Arrow Org
<