Sender
public final class Sender
extension CoChannel.Sender: CoCancellable
A CoChannel
wrapper that provides send-only functionality.
-
The type of channel buffer.
Declaration
Swift
@inlinable public var bufferType: BufferType { get }
-
Returns a number of elements in this channel.
Declaration
Swift
@inlinable public var count: Int { get }
-
Returns
true
if the channel is empty (contains no elements), which means no elements to receive.Declaration
Swift
@inlinable public var isEmpty: Bool { get }
-
Sends the element to this channel, suspending the coroutine while the buffer of this channel is full. Must be called inside a coroutine.
Throws
CoChannelError when canceled or closed.Declaration
Swift
@inlinable public func awaitSend(_ element: Element) throws
Parameters
element
Value that will be sent to the channel.
-
Immediately adds the value to this channel, if this doesn’t violate its capacity restrictions, and returns true. Otherwise, just returns false.
Declaration
Swift
@discardableResult @inlinable public func offer(_ element: Element) -> Bool
Parameters
element
Value that might be sent to the channel.
Return Value
true
if sent successfully orfalse
if channel buffer is full or channel is closed or canceled.
-
Closes this channel. No more send should be performed on the channel.
Declaration
Swift
@discardableResult @inlinable public func close() -> Bool
Return Value
true
if closed successfully orfalse
if channel is already closed or canceled. -
Returns
true
if the channel is closed.Declaration
Swift
@inlinable public var isClosed: Bool { get }
-
Closes the channel and removes all buffered sent elements from it.
Declaration
Swift
@inlinable public func cancel()
-
Returns
true
if the channel is canceled.Declaration
Swift
@inlinable public var isCanceled: Bool { get }