[WIP] First pass at some documentation for AsyncChannel (#91)

* First pass at some documentation for AsyncChannel

* Apply suggestions from code review

Co-authored-by: Chris Adamson <invalidname@gmail.com>

* Manually line break docs

Co-authored-by: Chris Adamson <invalidname@gmail.com>
This commit is contained in:
Philippe HauslerandChris Adamson authored and GitHub committed 2022-03-18 11:39:45 -07:00
1 parent 37ad908591
commit bcd0ee1e50
2 files changed
+19

No files matched your search

@@ -9,6 +9,9 @@
//
//===----------------------------------------------------------------------===//
/// A throwing channel for sending elements from on task to another with back pressure.
///
/// The `AsyncThrowingChannel` class is intended to be used as a communication types between tasks., particularly when one task produces values and another task consumes those values. The back pressure applied by `send(_:)`, `fail(_:)` and `finish()` via the suspension/resume ensure that the production of values does not exceed the consumption of values from iteration. Each of these methods suspends after enqueuing the event and is resumed when the next call to `next()` on the `Iterator` is made.
public final class AsyncThrowingChannel<Element: Sendable, Failure: Error>: AsyncSequence, Sendable {
public struct Iterator: AsyncIteratorProtocol, Sendable {
let channel: AsyncThrowingChannel<Element, Failure>