ReceiveOnly

public final class ReceiveOnly : Handle

Receive-only reference to an existing channel.

Example:

let channel = Channel<Int>()

func receive(from channel: Channel<Int>.ReceiveOnly) throws {
    let value = try channel.receive(deadline: 1.second.fromNow())
}

try receive(from: channel.receiveOnly)
  • Receives a value from channel.

    Declaration

    Swift

    @discardableResult public func receive(deadline: Deadline) throws -> Type
  • Mark the channel as done. When a channel is marked as done it cannot receive or send anymore.

    Declaration

    Swift

    public func done() throws