AsyncSelector

zio.blocks.async.AsyncSelector
See theAsyncSelector companion object
final class AsyncSelector[A] extends Cancelable

A repeatable, round-robin selector for independently pending computations.

Eligibility means that a slot is armed (initially, or by replace) and its computation has completed. Among eligible slots selection scans cyclically from the slot after the previous winner. Consequently a continuously eligible slot wins within at most armedCount successful selections.

The selector registers one stable waker per armed slot, rather than a new loser waker per call to select. A winning slot is disarmed atomically and cannot win twice. shutdown is idempotent and does not finish until cleanup for every still-armed loser has finished.

Attributes

Companion
object
Source
AsyncSelector.scala
Graph
Supertypes
trait Cancelable
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def cancel(): Unit

Stop the driver loop. Idempotent and synchronous; a no-op after the run has completed. See the trait documentation for the cancellation contract.

Stop the driver loop. Idempotent and synchronous; a no-op after the run has completed. See the trait documentation for the cancellation contract.

Attributes

Definition Classes
Source
AsyncSelector.scala
def replace(index: Int, value: => encoding.Async[A]): Unit

Arm a disarmed slot with its next computation.

Arm a disarmed slot with its next computation.

Attributes

Source
AsyncSelector.scala
def select: encoding.Async[(Int, A)]

Wait for and remove the next winner, returning its slot and value.

Wait for and remove the next winner, returning its slot and value.

Attributes

Source
AsyncSelector.scala
def shutdown: encoding.Async[Unit]

Cancel all armed inputs and join all cleanup. Idempotent.

Cancel all armed inputs and join all cleanup. Idempotent.

Attributes

Source
AsyncSelector.scala
def size: Int

Number of slots, including currently disarmed slots.

Number of slots, including currently disarmed slots.

Attributes

Source
AsyncSelector.scala

Inherited methods

final def close(): Unit

Alias for cancel() so a running handle works as an AutoCloseable.

Alias for cancel() so a running handle works as an AutoCloseable.

Attributes

Inherited from:
Cancelable
Source
Cancelable.scala