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

Add async .Merge() #29

Closed
viceroypenguin opened this issue Jul 13, 2022 · 2 comments · Fixed by #35
Closed

Add async .Merge() #29

viceroypenguin opened this issue Jul 13, 2022 · 2 comments · Fixed by #35
Milestone

Comments

@viceroypenguin
Copy link
Owner

See morelinq/MoreLINQ#793

@Arithmomaniac
Copy link
Contributor

How does this implementation compare to Merge (the array version, not the broken enumerable version)?

@viceroypenguin
Copy link
Owner Author

Primary difference is that .ConcurrentMerge() allows limiting how many operations are concurrently in flight.

Secondary difference is methodology:

  • .Merge() does a full pass of all enumerators and triggers a .MoveNextAsync(). Then waits for all of them to complete, returning elements as they complete. This means that all enumerators are moved forward in lockstep. Faster processes will have to wait for slower ones.
  • .ConcurrentMerge() triggers .MoveNextAsync() until it reaches a non-completed task. Then it immediately checks for any that are completed; clear out whichever are completed; and keep going. This means quicker enumerators can generate values quickly while slower ones can process in background.

.Merge() is more "fair" to force fast ones to wait for slow ones, while .ConcurrentMerge() returns values asap regardless of where they come from.

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

Successfully merging a pull request may close this issue.

2 participants