Allow scheduling of CF completion in parallel#277
Conversation
| clearCacheKeys.add(key); | ||
| } | ||
| } else { | ||
| future.complete(value); |
There was a problem hiding this comment.
This misses the Try path of completion
|
@fxbonnet I am not sure about this PR: with the new hook introduced by @bbakerman in #275 you can already offload every completion onto a new thread and hence it will run in parallel if you choose todo so. I have problems seeing how this approach is different/better. |
…potentially in parallel
dd2af99 to
e04c76d
Compare
|
@andimarek I created this PR after my comment on @bbakerman 's PR #275 (comment) |
| } | ||
|
|
||
| List<K> clearCacheKeys = new ArrayList<>(); | ||
| Collection<K> clearCacheKeys = new ConcurrentLinkedQueue<>(); |
There was a problem hiding this comment.
clearCacheKeys may now be accessed concurrently by multiple thread if we execute the Runnables in parallel.
There was a problem hiding this comment.
good call - price of side effects outside a thread
When a batch loading function returns, we currently complete all
CompletableFutures sequentially on the calling thread. SinceCompletableFuture.complete(...)also executes any continuations attached viathenApply(...)orthenCompose(...), large batches can significantly delay the return ofdispatch().This PR introduces an option to execute these continuations in parallel instead.