@@ -3055,21 +3055,21 @@ static final class MinimalStage<T> extends CompletableFuture<T> {
3055
3055
* @throws NullPointerException if the collection or any of its elements are null
3056
3056
* @since 99
3057
3057
*/
3058
- public static <T > Stream <CompletableFuture <T >> completed (Collection <? extends CompletableFuture <T >> cfs ) {
3059
- if (cfs .size () == 0 )
3060
- return Stream .empty ();
3061
- var queue = new LinkedTransferQueue <CompletableFuture <T >>();
3062
- int count = 0 ;
3063
- for (CompletableFuture <T > cf : cfs ) {
3064
- cf .handle ((result , exc ) -> {
3065
- queue .add (cf );
3066
- return null ;
3067
- });
3068
- count ++;
3069
- }
3070
- Spliterator <CompletableFuture <T >> s = new BlockingQueueSpliterator <>(queue , count );
3071
- return StreamSupport .stream (s , false );
3072
- }
3058
+ // public static <T> Stream<CompletableFuture<T>> completed(Collection<? extends CompletableFuture<T>> cfs) {
3059
+ // if (cfs.size() == 0)
3060
+ // return Stream.empty();
3061
+ // var queue = new LinkedTransferQueue<CompletableFuture<T>>();
3062
+ // int count = 0;
3063
+ // for (CompletableFuture<T> cf : cfs) {
3064
+ // cf.handle((result, exc) -> {
3065
+ // queue.add(cf);
3066
+ // return null;
3067
+ // });
3068
+ // count++;
3069
+ // }
3070
+ // Spliterator<CompletableFuture<T>> s = new BlockingQueueSpliterator<>(queue, count);
3071
+ // return StreamSupport.stream(s, false);
3072
+ // }
3073
3073
3074
3074
/**
3075
3075
* Returns a stream that is lazily populated with the given CompletableFutures
@@ -3085,71 +3085,71 @@ public static <T> Stream<CompletableFuture<T>> completed(Collection<? extends Co
3085
3085
* @throws NullPointerException if the array or any of its elements are null
3086
3086
* @since 99
3087
3087
*/
3088
- @ SafeVarargs
3089
- @ SuppressWarnings ("varargs" )
3090
- public static <T > Stream <CompletableFuture <T >> completed (CompletableFuture <T >... cfs ) {
3091
- int size = cfs .length ;
3092
- if (size == 0 )
3093
- return Stream .empty ();
3094
- var queue = new LinkedTransferQueue <CompletableFuture <T >>();
3095
- for (CompletableFuture <T > cf : cfs ) {
3096
- cf .handle ((result , exc ) -> {
3097
- queue .add (cf );
3098
- return null ;
3099
- });
3100
- }
3101
- Spliterator <CompletableFuture <T >> s = new BlockingQueueSpliterator <>(queue , size );
3102
- return StreamSupport .stream (s , false );
3103
- }
3088
+ // @SafeVarargs
3089
+ // @SuppressWarnings("varargs")
3090
+ // public static <T> Stream<CompletableFuture<T>> completed(CompletableFuture<T>... cfs) {
3091
+ // int size = cfs.length;
3092
+ // if (size == 0)
3093
+ // return Stream.empty();
3094
+ // var queue = new LinkedTransferQueue<CompletableFuture<T>>();
3095
+ // for (CompletableFuture<T> cf : cfs) {
3096
+ // cf.handle((result, exc) -> {
3097
+ // queue.add(cf);
3098
+ // return null;
3099
+ // });
3100
+ // }
3101
+ // Spliterator<CompletableFuture<T>> s = new BlockingQueueSpliterator<>(queue, size);
3102
+ // return StreamSupport.stream(s, false);
3103
+ // }
3104
3104
3105
3105
/**
3106
3106
* Simple Spliterator with a BlockingQueue as its source. This implementation
3107
3107
* will be replaced if the APIs go forward beyond prototype.
3108
3108
*/
3109
- private static class BlockingQueueSpliterator <T >
3110
- implements Spliterator <CompletableFuture <T >> {
3111
-
3112
- final BlockingQueue <CompletableFuture <T >> queue ;
3113
- final int size ;
3114
- int taken ; // running count of the number of elements taken
3115
-
3116
- BlockingQueueSpliterator (BlockingQueue <CompletableFuture <T >> queue , int size ) {
3117
- this .queue = queue ;
3118
- this .size = size ;
3119
- }
3120
-
3121
- @ Override
3122
- public boolean tryAdvance (Consumer <? super CompletableFuture <T >> action ) {
3123
- Objects .requireNonNull (action );
3124
- if (taken >= size ) {
3125
- return false ;
3126
- } else {
3127
- CompletableFuture <T > cf ;
3128
- try {
3129
- cf = queue .take ();
3130
- } catch (InterruptedException e ) {
3131
- Thread .currentThread ().interrupt ();
3132
- throw new CancellationException ("Thread interrupted" );
3133
- }
3134
- taken ++;
3135
- action .accept (cf );
3136
- return true ;
3137
- }
3138
- }
3139
-
3140
- @ Override
3141
- public Spliterator <CompletableFuture <T >> trySplit () {
3142
- return null ;
3143
- }
3144
-
3145
- @ Override
3146
- public int characteristics () {
3147
- return Spliterator .SIZED + Spliterator .NONNULL ;
3148
- }
3149
-
3150
- @ Override
3151
- public long estimateSize () {
3152
- return size ;
3153
- }
3154
- }
3109
+ // private static class BlockingQueueSpliterator<T>
3110
+ // implements Spliterator<CompletableFuture<T>> {
3111
+ //
3112
+ // final BlockingQueue<CompletableFuture<T>> queue;
3113
+ // final int size;
3114
+ // int taken; // running count of the number of elements taken
3115
+ //
3116
+ // BlockingQueueSpliterator(BlockingQueue<CompletableFuture<T>> queue, int size) {
3117
+ // this.queue = queue;
3118
+ // this.size = size;
3119
+ // }
3120
+ //
3121
+ // @Override
3122
+ // public boolean tryAdvance(Consumer<? super CompletableFuture<T>> action) {
3123
+ // Objects.requireNonNull(action);
3124
+ // if (taken >= size) {
3125
+ // return false;
3126
+ // } else {
3127
+ // CompletableFuture<T> cf;
3128
+ // try {
3129
+ // cf = queue.take();
3130
+ // } catch (InterruptedException e) {
3131
+ // Thread.currentThread().interrupt();
3132
+ // throw new CancellationException("Thread interrupted");
3133
+ // }
3134
+ // taken++;
3135
+ // action.accept(cf);
3136
+ // return true;
3137
+ // }
3138
+ // }
3139
+ //
3140
+ // @Override
3141
+ // public Spliterator<CompletableFuture<T>> trySplit() {
3142
+ // return null;
3143
+ // }
3144
+ //
3145
+ // @Override
3146
+ // public int characteristics() {
3147
+ // return Spliterator.SIZED + Spliterator.NONNULL;
3148
+ // }
3149
+ //
3150
+ // @Override
3151
+ // public long estimateSize() {
3152
+ // return size;
3153
+ // }
3154
+ // }
3155
3155
}
0 commit comments