Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid stack overflow error with Future.reduce
This completely splits the implementation between the ordered and unordered reduce, as it becomes rather difficult to share code between the two. This tweaks the internal interface slightly, in particular by not using an instance variable for the accumulator in either case. With a long list of resolved futures, the previous implementation of an ordered reduce caused a stack-overflow exception, as each call to reduce_next happened within the previous call (synchronously). This changes the behavior to loop over futures instead of using recursion while on_complete dispatches synchronously in the same thread. The implementation is heavily based on the non-recursive implementation of Future.after
- Loading branch information
Showing
2 changed files
with
68 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters