The stored channel property of ChannelAndStream is intentionally
internal, so the documented consume channelAndSource.channel snippet
fails to compile for clients. The supported API is takeChannel(); use
it in both doc examples.
Signed-off-by: Aniket <aniketkomailkro@gmail.com>
* Rework `AsyncStreaming` protocols to use generic `RangeReplaceableContainer` buffers
Replace `InputSpan`/`OutputSpan` with generic `Buffer` associated types constrained to `RangeReplaceableContainer` across all four streaming protocols. This sidesteps the limitation that `OutputSpan` (and other `~Escapable` types) cannot be used in async contexts today, while still allowing conforming types to choose a buffer representation optimized for their use case (e.g. `UniqueArray` for heap-backed storage, or a future stack-allocated container for embedded).
Switch callee-owned protocols from `consuming` to `inout` closure semantics, rename `forEachChunk` to `forEachBuffer`, and move `forEach`/`collect` to future directions in the proposal.
Adds test coverage for `AsyncWriter`, `CallerAsyncReader`, and `EitherError`. Updates all documentation to reflect the new API surface.
* Fix a few new region isolation errors in `nightly-main`
Region isolation got smarter and started diagnosing more potential data races. This PR addresses the new errors. Importantly I had to introduce one `@unchecked Sendable` conformance since we can't yet use `UniqueDeque`
We added a little helper to move a non-Sendable type into an optional and take it out as sending so that it is disconnected. This was actually a data race hole which got fixed by the compiler so we need to use a proper disconnected abstractions.
`nonisolated(nonsending)` is a 6.2 language feature that allows the inheritance of the callers isolation. The new `MPSCAsyncChannel.Source` send methods should adopt this to avoid unnecessary isolation hops.
* Add `AsyncBackpressuredStream` proposal and implementation
# Motivation
The pitch to add external backpressure support to the standard libraries `AsyncStream` got returned for revision since there are larger open questions around `AsyncSequence`. However, having external backpressure in a source asynchronous sequence is becoming more and more important.
# Modification
This PR adds a modified proposal and implementation that brings the Swift Evolution proposal over to Swift Async Algorithms.
* Update proposal and implementation
* Update proposal
* Add example project
* Formatting
* Fix Swift 6.0 build
* Future direction for ~Copyable elements
* Apply formatting
* Fix CI
* Move to 6.1 and update proposal
* Guard tests
* Minor edits to the proposal
* Fix revision order
* FIxup setOnTerminationCallback
* Address review feedback
* Rename to `MultiProducerSingleConsumerAsyncChannel`
* Allow one termination callback per source.
* Fix all sendable warnings
* Remove unbounded strategy, rename copy -> makeAdditionalSource, rename asyncSequence() -> elements(), and move enqueue and cancel to the `CallbackHandle` previously called `CallbackToken`
* Remove Example and fix docs and fix format
* fixes grammar and some word order issues
* Remove unnecessary consume
---------
Co-authored-by: Joe Heck <j_heck@apple.com>