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

1.x: CombineLatest now supports any number of sources #3661

Merged
merged 1 commit into from
Feb 3, 2016

Conversation

akarnokd
Copy link
Member

@akarnokd akarnokd commented Feb 1, 2016

This PR is a backport of the 2.x combineLatest with null support and let's the programmer combine more than 128 sources at once. Note that 2.x supports manual sizing of the prefetch buffer and allows delaying the exceptions to the last moment; I kept these in case such features are required by 1.x some day.

The original had this 128 limit due to using a single and non-parametric RxRingBuffer to store values from sources. In addition, the original algorithm divided downstream requests among the sources with some strange logic in order to keep them running and not overflow the buffer.

This PR uses an unbounded-linked SPSC queue which can now hold as many elements as there are sources times the default ring buffer size (this is not preallocated and grows/shrinks as necessary).

The algorithm stores the current latest array and the source subscriber in the queue in pairs so when that particular row is emitted to downstream, that source subscriber gets the request() replenishment call that generated the row.

In addition, I've added an Iterator overload from #3660 as well.

@JakeWharton
Copy link
Contributor

Thanks!

@stevegury
Copy link
Member

👍

akarnokd added a commit that referenced this pull request Feb 3, 2016
1.x: CombineLatest now supports any number of sources
@akarnokd akarnokd merged commit cd9a6ec into ReactiveX:1.x Feb 3, 2016
@akarnokd akarnokd deleted the CombineLatestManyV3 branch February 3, 2016 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants