SendChannel

interface SendChannel<T>

代表一个只能发送(send)元素的通道。

这是一个用于单向通信的原语,其中协程可以向通道发送数据, 而另一端的消费者可以接收这些数据。

Author

M8Test, [email protected], https://m8test.com

Parameters

T

可以发送到此通道的元素的类型。

Inheritors

Functions

Link copied to clipboard
abstract fun isClosedForSend(): Boolean

当前通道是否已关闭发送端

Link copied to clipboard
abstract fun send(scope: CoroutineScope, value: T): Deferred<Unit>

异步地向通道发送一个元素,并在必要时挂起。

Link copied to clipboard
abstract fun trySend(element: T): ChannelResult<Unit>

尝试立即向通道发送一个元素,不会挂起。