Skip to content

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