Skip to content
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

Channel implementation with zero capacity #987

Open
johnhungerford opened this issue Jan 9, 2025 · 0 comments
Open

Channel implementation with zero capacity #987

johnhungerford opened this issue Jan 9, 2025 · 0 comments

Comments

@johnhungerford
Copy link
Contributor

Streaming from channels currently uses drainUpTo on the underlying Queue to grab chunks from the channel. Since there is no queue for zero-capacity channels, they will necessarily stream one element at a time (that is, chunks of size 1 -- essentially a loop over take), even though there may be multiple pending puts that could be drained.

It probably makes sense to provide a special implementation for channels of capacity zero that has no main queue and simply passes values directly from the pending puts to the pending takes. drain and drainUpTo could be specialized to drain the puts. Since there is no queue for these to pass to, there is no issue with ordering to worry about (which is why regular channels only drain the main queue and not the puts).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants