Skip to content

Commit 30aa87c

Browse files
committedApr 20, 2021
disable completed methods for now
1 parent a2d3f09 commit 30aa87c

File tree

2 files changed

+77
-261
lines changed

2 files changed

+77
-261
lines changed
 

‎src/java.base/share/classes/java/util/concurrent/CompletableFuture.java

+77-77
Original file line numberDiff line numberDiff line change
@@ -3055,21 +3055,21 @@ static final class MinimalStage<T> extends CompletableFuture<T> {
30553055
* @throws NullPointerException if the collection or any of its elements are null
30563056
* @since 99
30573057
*/
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+
// }
30733073

30743074
/**
30753075
* 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
30853085
* @throws NullPointerException if the array or any of its elements are null
30863086
* @since 99
30873087
*/
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+
// }
31043104

31053105
/**
31063106
* Simple Spliterator with a BlockingQueue as its source. This implementation
31073107
* will be replaced if the APIs go forward beyond prototype.
31083108
*/
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+
// }
31553155
}

‎test/jdk/java/lang/Thread/virtual/Completed.java

-184
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.