Structure_Concurrency5.9.0
Continuation
A mechanism to interface between synchronous code and an asynchronous stream.
- iOS
- 13.0+
- macOS
- 10.15+
- tvOS
- 13.0+
- watchOS
- 6.0+
struct Continuation
The closure you provide to the AsyncStream
in init(_:bufferingPolicy:_:)
receives an instance of this type when invoked. Use this continuation to provide elements to the stream by calling one of the yield
methods, then terminate the stream normally by calling the finish()
method.
Citizens in _Concurrency
Conformances
protocol Sendable
A type whose values can safely be passed across concurrency domains by copying.
Members
var onTermination: ((AsyncStream<Element>.Continuation.Termination) -> Void)?
A callback to invoke when canceling iteration of an asynchronous stream.
func finish(
) Resume the task awaiting the next iteration point by having it return nil, which signifies the end of the iteration.
func yield(
) -> AsyncStream<Element>.Continuation.YieldResult Resume the task awaiting the next iteration point by having it return normally from its suspension point.
func yield(Element
) -> AsyncStream<Element>.Continuation.YieldResult Resume the task awaiting the next iteration point by having it return normally from its suspension point with a given element.
func yield(with: Result<Element, Never>
) -> AsyncStream<Element>.Continuation.YieldResult Resume the task awaiting the next iteration point by having it return normally from its suspension point with a given result’s success value.
enum BufferingPolicy
A strategy that handles exhaustion of a buffer’s capacity.
enum Termination
A type that indicates how the stream terminated.
enum YieldResult
A type that indicates the result of yielding a value to a client, by way of the continuation.