[Channels] implement AsyncBufferedChannel #229
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi.
This PR is a draft implementation of the variant to
AsyncChannel
mentioned in this thread -> https://forums.swift.org/t/asyncchannel-should-we-allow-to-buffer/60876/12Here the description:
As discussed in the forum, it does not necessarely target the v1.0.
That being said, I think we can reuse the same kind of implementation (state machine / storage / async sequence) for
AsyncChannel
as it better separates the concerns and it is now the "default" implementation when there is a shared state to manage between producers/consumers or racing tasks.Also, as mentioned here -> https://forums.swift.org/t/pitch-async-buffered-channel/59854/9 we might want to move away from the "all-in-one" paradigm in favour of a pair
continuation/async sequence
as pitched by @FranzBusch forAsyncStream
. In that case the implementation is still valid by reusing the storage in both parts.I have intentionally not implemented the throwing version waiting for more feedback from the community.
@phausler @FranzBusch I guess you are the ones that can review it when this is the right timing.