Skip to content

SharedReceiver

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.

SharedReceiver

A shared consumer; queued values remain available after the last producer closes.

shared public class SharedReceiver<T: shared>

clone

Creates an independently closable consumer on the same queue.

public fun clone(): SharedReceiver<T>

try_receive

Attempts one receive, distinguishing Empty, closed endpoints, and drained EOF.

public fun try_receive(): Result<Option<T>, ChannelError>

receive

Waits for a value or drained EOF using cross-worker notifications.

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

close

Closes this endpoint; the last consumer releases queued values and wakes blocked sends.

public fun close(): void