-
-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify the BufferedAsyncIterator and runner fetch driver
The goal of that iterator is to take a number of promises in unknown states, and generate their results in the order of these promises resolving/rejecting. This commit changes the implementation in such a way that we do not need an event emitter *and* a result queue and a (fairly complex) logic of synchronizing these. Instead the iterator builds two parallel queues, one containing unresolved promises and one containing the [resolve, reject] functions for these promises. The incoming promises then are configured to pop the next [resolve, reject] pair, and call that with the respective result. The iterator at the same time picks the next unresolved promise from its own queue, and `awaits` the result. On the runner side this requires to `await` the iterator.next(), which actually simplifies more code by removing the need for a separate queue of "enqueued tasks". Note that this code also removes the configurable "handleError" logic without replacement: No caller ever provided that, so the default of "throw the error further" is good enough.
- Loading branch information
Showing
2 changed files
with
65 additions
and
120 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