AsyncThrowingStream

extension AsyncThrowingStream

Initialization

  • Construct a AsyncThrowingStream buffering given an Element type.

    The maximum number of pending elements limited by dropping the oldest value when a new value comes in if the buffer would excede the limit placed upon it. By default this limit is unlimited.

    The build closure passes in a Continuation which can be used in concurrent contexts. It is thread safe to send and finish; all calls are to the continuation are serialized, however calling this from multiple concurrent contexts could result in out of order delivery.

    Declaration

    Swift

    public init(
        _ elementType: Element.Type = Element.self,
        bufferingPolicy limit: AsyncThrowingStream<Element, Failure>.Continuation.BufferingPolicy = .unbounded,
        _ build: @escaping (AsyncThrowingStream<Element, Failure>.Continuation) async -> Void
    ) where Failure == Error

    Parameters

    elementType

    The type the AsyncThrowingStream will produce.

    maxBufferedElements

    The maximum number of elements to hold in the buffer past any checks for continuations being resumed.

    build

    The work associated with yielding values to the AsyncThrowingStream.

AsyncThrowingStream.Continuation