actorAsync

fun <T> CoroutineScope.actorAsync(channelCapacity: Int = Channel.UNLIMITED, markerFactory: suspend (T) -> Any? = { null }, logger: KSLog = KSLog, block: suspend (T) -> Unit): Channel<T>(source)

Creates an actor-style channel that processes messages asynchronously based on markers. Messages with the same marker will be processed sequentially, while messages with different markers can be processed concurrently.

Return

A Channel that accepts messages to be processed

Parameters

channelCapacity

The capacity of the underlying channel. Defaults to Channel.UNLIMITED

markerFactory

A factory function that produces a marker for each message. Messages with the same marker will be processed sequentially. Defaults to returning null, meaning all messages will be processed sequentially

logger

The logger instance used for logging exceptions. Defaults to KSLog

block

The suspending function that processes each message

Type Parameters

T

The type of messages to process