arrow-fx / arrow.fx / Dequeue / peekAll
abstract fun peekAll(): Kind<F,
List
<A>>
Immediately returns all available values in the Queue, without empty’ing the Queue. It returns an emptyList when no values are available.
import arrow.fx.*
import arrow.fx.extensions.fx
//sampleStart
suspend fun main(args: Array<String>): Unit = IO.fx {
val queue = !Queue.unbounded<Int>()
!queue.offerAll(1, 2, 3, 4)
val values = !queue.peekAll()
val values2 = !queue.peekAll()
!effect { println("values: $values, values2: values2") }
}.suspended()
//sampleEnd
For a BackpressureStrategy.Bounded, this also includes all blocking offers that are waiting to be added in the Queue.
See Also
Do you like Arrow?
✖