Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Support async processing while maintaining output order #1215

Merged
merged 6 commits into from
Apr 4, 2019

Conversation

ajsutton
Copy link
Contributor

@ajsutton ajsutton commented Apr 4, 2019

PR description

Adds a thenProcessAsyncOrdered function to PipelineBuilder so that operations can be processed asynchronously, with multiple operations happening concurrently, but ensure that outputs are in the same order as inputs.

Also fixes a potential performance issue caused by using CompletableFuture.anyOf too much. Each call adds completion actions to the futures involved which are never removed, so when they eventually complete they have a huge stack of actions to notify which can take significant time. Caching the result keeps the number of actions to a reasonable level.

Also fixes an issue where the pipeline was not aborted if an asynchronous operation completed exceptionally.

Fixed Issue(s)

https://pegasys1.atlassian.net/browse/PAN-2527

}

/**
* CompletableFuture.anyOf adds a completion handler to every future its passed so if we call it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it help to cancel the future returned from anyOf when you overwrite it??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly no, it looks like it only cleans the completion stack when the underlying futures complete.

@ajsutton ajsutton merged commit 46d2af7 into PegaSysEng:master Apr 4, 2019
@ajsutton ajsutton deleted the pipeline-async-ordered branch April 4, 2019 20:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants