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

2.x: fix scan(seed, f) to emit accumulated values asap #5090

Merged
merged 1 commit into from
Feb 11, 2017

Conversation

akarnokd
Copy link
Member

For performance reasons, the scan delayed the emission of accumulated items by one which worked well with sources that pushed new items frequently.

Unfortunately, if the source stopped emitting (without completion), the very last accumulated item was stuck and no way to get it out of scan. I considered this type of use being rare but apparently I was wrong.

The PR changes scan to emit accumulated items, including the initial seed, as soon as there is request for it. The operator now uses a stable-prefetch queue-drain found throughout other operators such as observeOn.

Remark: sadly, request trickery such as capturing the first request call, emitting the seed and then requesting n - 1 doesn't work because if the request() call itself happens from another thread and the source is empty, the onNext and onComplete could run concurrently.

Reported in #5089

@akarnokd akarnokd added this to the 2.0 backlog milestone Feb 10, 2017
@akarnokd akarnokd merged commit 28d1352 into ReactiveX:2.x Feb 11, 2017
@akarnokd akarnokd deleted the ScanNoDelay branch February 11, 2017 09:37
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.

2 participants