-
Notifications
You must be signed in to change notification settings - Fork 59
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: drain/drainUpTo include pending puts #980
Conversation
Co-authored-by: Adam Hearn <22334119+hearnadam@users.noreply.github.com>
Co-authored-by: Adam Hearn <22334119+hearnadam@users.noreply.github.com>
Co-authored-by: Adam Hearn <22334119+hearnadam@users.noreply.github.com>
…yo into drain-take-pending-puts
@fwbrasil @hearnadam this update produces a potential issue: when streaming from a channel, there is no guarantee that you will consume elements in order. In So I guess the question is do we care that order is not preserved? |
Maintaining ordering would be ideal. What if we had a cycle of queue.drainUpTo/flush/queue.drainUpTo/flush/.. until drainUpTo returns empty? It wouldn't handle the case where the channel/queue has capacity 0 but it might be ok. I've been thinking that we should have a separate impl for channels without capacity |
Good idea, that works nicely. |
…0-capacity pending puts test
If maintaining order is required, our current batched The only solution I see to this is to add a stack of |
More relaxed ordering when the queue becomes full and there are multiple concurrent puts seems more reasonable given that concurrent puts can arrive in any order. To ensure ordering even in this scenario, I think we'd need to have a single atomic operation instead of having to deal with both the main queue and the pending takes/puts queues, which I think wouldn't allow some of the fast paths we currently have in the implementation like |
…yo into drain-take-pending-puts
closes #978