NIOAsyncWriter
A NIOAsyncWriter
is a type used to bridge elements from the Swift Concurrency domain into a synchronous world. The Task
s that are yielding to the NIOAsyncWriter
are the producers. Whereas the NIOAsyncWriterSinkDelegate
is the consumer.
- iOS
- 13+
- macOS
- 10.15+
- tvOS
- 13+
- watchOS
- 6+
struct NIOAsyncWriter<Element, Delegate> where Element == Delegate.Element, Delegate : NIOAsyncWriterSinkDelegate
Additionally, the NIOAsyncWriter
allows the consumer to set the writability by calling setWritability(to:)
. This allows the implementation of flow control on the consumer side. Any call to yield(contentsOf:)
or yield(_:)
will suspend if the NIOAsyncWriter
is not writable and will be resumed after the NIOAsyncWriter
becomes writable again or if the NIOAsyncWriter
has finished.