Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is intended to fix #74
The problem it that case is that
MergeProducer#_stop
method never gets called because of cancelled async stoppage. So when original stream gets executed second time and then completed, theac
counter goes to -1 and that doesn't lead to merged stream completion.The idea of PR is that we can be sure about (virtual) count of active listeners right before we iterate through
insArr
and call_add
s, because each of the incoming streams either runs already or gets started by_add
.There's still a potential problem in case if some incoming stream gets restarted by another listener. To fix that,
merge
should be rewritten in the manner ofcombine
to track which of the streams actually completes.