actor

fun <T> CoroutineScope.actor(channelCapacity: Int = Channel.UNLIMITED, block: suspend (T) -> Unit): Channel<T>(source)

Creates an actor using coroutines that processes incoming messages of type T. An actor is a computational entity that processes messages sequentially in response to messages it receives.

Return

A Channel that can be used to send messages to this actor or cancel it

Parameters

T

The type of messages this actor will process

channelCapacity

The capacity of the Channel used for message delibery to the actor. Defaults to Channel.UNLIMITED

block

The processing logic to be applied to each received message