-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use List<> instead of Stream.Builder<> as accumulators
- Loading branch information
Showing
5 changed files
with
32 additions
and
37 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
5 changes: 3 additions & 2 deletions
5
src/main/java/com/pivovarit/collectors/CompletionStrategy.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
package com.pivovarit.collectors; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.function.Function; | ||
import java.util.stream.Stream; | ||
import java.util.stream.StreamSupport; | ||
|
||
interface CompletionStrategy<T> extends Function<Stream<CompletableFuture<T>>, Stream<T>> { | ||
interface CompletionStrategy<T> extends Function<List<CompletableFuture<T>>, Stream<T>> { | ||
|
||
static <R> CompletionStrategy<R> unordered() { | ||
return futures -> StreamSupport.stream(new CompletionOrderSpliterator<>(futures), false); | ||
} | ||
|
||
static <R> CompletionStrategy<R> ordered() { | ||
return futures -> futures.map(CompletableFuture::join); | ||
return futures -> futures.stream().map(CompletableFuture::join); | ||
} | ||
} |
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