-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a proposal for AsyncChannel #216
Conversation
Hi @phausler should we consider this https://forums.swift.org/t/asyncchannel-should-we-allow-to-buffer/60876/8 for the v1 ? |
@twittemb my initial gut reaction is that the buffering variants should be their own types, provided they need a slightly different interface as you were suggesting? Now if they can be done with the same interface but just some extra knobs/dials on the initialization then perhaps we can add that as a 1.1 improvement? Particularly for the channel type I want there to be a very easy on-ramp to more complex functionality; as the programmatic understanding becomes more complex the interface can grow in complexity; leaving the more simple concepts more simple to use and the advanced concepts gradually come at the cost of more advance use. |
@phausler I was seeing the same interface with an The There is still something I'm not sure of (perhaps you can tell): I'm not sure we can "not suspend" at all if the buffer has slots, or if we have to suspend/resume immediately in an atomic operation. Let's say that we HAVE to suspend/resume immediately (because of the way concurrency is managed with ManagedCriticalState + Continuations), do we still have a benefit (performance wise) ? |
Does it make sense to have the default of the init be the 0 case as we have it? Per the "not suspend" part: it is 100% reasonable to have an async method that conditionally suspends sometimes and not others; after all that is how the Do you have any prototypes yet of that? TBH AsyncChannel's internals can definitely be optimized (and simplified I think). For other reasons I would like to step up our proposals to get to a 1.0 asap. So from a delivery standpoint it makes sense to have that as a future direction. |
I left a comment on the forums post. Maybe we can keep the discussion over there to consolidate all views. |
I've added a reply to the thread -> https://forums.swift.org/t/pitch-async-buffered-channel/59854/8 regarding consistency between |
Hey @phausler do you have a take on the |
The Returning similar result based on the return reason:
will help community to use channel building custom data structures. |
This proposal has been accepted. So merging this PR. |
This proposal formalizes the AsyncChannel and AsyncThrowingChannel types.
Read the full proposal here.