arrow-fx-stm / arrow.fx.stm / STM / removeAll
open fun <A>
TQueue
<A>.removeAll(pred: (A) ->
Boolean
):
Unit
Filter a TQueue, removing all elements for which pred returns false.
import arrow.fx.stm.TQueue
import arrow.fx.stm.atomically
suspend fun main() {
//sampleStart
val tq = TQueue.new<Int>()
atomically {
tq.write(0)
tq.removeAll { it != 0 }
}
//sampleEnd
println("Items in queue ${atomically { tq.flush() }}")
}
This function never retries.
This function has to access both TVar’s and thus may lead to increased contention, use sparingly.
Do you like Arrow?
✖