Skip to content

SharedSender

1 min read

Import: import system.task;

Read the usage guide for examples and common tasks. This reference lists the public declarations for this part of the library. See Reading API signatures for parameter and result notation.

SharedSender

A shared producer; clone creates an independent endpoint and ordinary aliases share closure.

shared public class SharedSender<T: shared>

clone

Creates another producer; the queue closes after the last producer closes or drops.

public fun clone(): SharedSender<T>

try_send

Attempts one send atomically without blocking the scheduler.

public fun try_send(value: T): Result<Unit, ChannelError>

send

Waits for capacity using cross-worker notifications and inherited cancellation.

public fun send(
    value: T,
    token: Option<CancellationToken> = Option.None
): Future<Result<Unit, ChannelError>>

close

Closes this endpoint atomically and wakes affected producers and consumers.

public fun close(): void