Channel

public enum Channel

A namespace for types and convenience methods related to channels.

For details on channels, see ChannelProtocol.

  • Bounded, single-slot, single-sender channel (AKA rendez-vous). Unbuffered channels are safe to use from any executor.

    See more

    Declaration

    Swift

    public enum Unbuffered<Item> : ChannelProtocol
  • Creates a bounded, single-slot, single-sender (AKA rendez-vous) channel. Unbuffered channels are safe to use from any executor.

    Declaration

    Swift

    @inlinable
    public static func makeUnbuffered<T>(itemType _: T.Type = T.self) -> Pipe<Unbuffered<T>>
  • Unbounded, single-slot, single-sender channel (AKA passthrough). Passthrough channels must only be used from a single executor.

    See more

    Declaration

    Swift

    public enum Passthrough<Item> : UnboundedChannelProtocol
  • Creates an unbounded, single-slot, single-sender (AKA passthrough) channel. Passthrough channels must only be used from a single executor.

    Declaration

    Swift

    @inlinable
    public static func makePassthrough<T>(itemType _: T.Type = T.self) -> Pipe<Passthrough<T>>
  • Unbounded, buffered, single-sender channel. Buffered channels are safe to use from any executor.

    See more

    Declaration

    Swift

    public enum BufferedUnbounded<Item> : UnboundedChannelProtocol
  • Creates an unbounded, buffered, single-sender channel. Buffered channels are safe to use from any executor.

    Declaration

    Swift

    @inlinable
    public static func makeBuffered<T>(itemType _: T.Type = T.self) -> Pipe<BufferedUnbounded<T>>
  • Bounded, buffered, multiple-sender channel. Shared channels are safe to use from any executor.

    See more

    Declaration

    Swift

    public enum Shared<Item> : ChannelProtocol
  • Creates a bounded, buffered, multiple-sender channel with the specified capacity. Shared channels are safe to use from any executor.

    Declaration

    Swift

    @inlinable
    public static func makeShared<T>(itemType _: T.Type = T.self, capacity: Int) -> Pipe<Shared<T>>
  • Unbounded, buffered, multiple-sender channel. Shared channels are safe to use from any executor.

    See more

    Declaration

    Swift

    public enum SharedUnbounded<Item> : UnboundedChannelProtocol
  • Creates an unbounded, buffered, multiple-sender channel. Shared channels are safe to use from any executor.

    Declaration

    Swift

    @inlinable
    public static func makeShared<T>(itemType _: T.Type = T.self) -> Pipe<SharedUnbounded<T>>
  • Bundles together the sending and receiving sides of a channel.

    The channel is kept open for as long as the pipe is kept alive. You may obtain separate handles to each side using Pipe.split(), let the pipe go and manage each side lifetime separately. This is useful when the sender and receiver have different lifetimes; dropping either side closes the channel.

    Pipe is typically known as Subject in other frameworks.

    See more

    Declaration

    Swift

    public struct Pipe<C> : SinkConvertible, StreamConvertible where C : ChannelProtocol