ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/CompletionStage.java
Revision: 1.6
Committed: Sat Jul 6 08:12:30 2013 UTC (10 years, 10 months ago) by jsr166
Branch: MAIN
Changes since 1.5: +1 -0 lines
Log Message:
whitespace

File Contents

# Content
1 /*
2 * Written by Doug Lea with assistance from members of JCP JSR-166
3 * Expert Group and released to the public domain, as explained at
4 * http://creativecommons.org/publicdomain/zero/1.0/
5 */
6
7 package java.util.concurrent;
8 import java.util.function.Supplier;
9 import java.util.function.Consumer;
10 import java.util.function.BiConsumer;
11 import java.util.function.Function;
12 import java.util.function.BiFunction;
13 import java.util.concurrent.Executor;
14
15 /**
16 * A stage of a possibly asynchronous computation, that performs an
17 * action or computes a value when another CompletionStage completes.
18 * A stage completes upon termination of its computation, but this may
19 * in turn trigger other dependent stages. The functionality defined
20 * in this interface takes only a few basic forms, which expand out to
21 * a larger set of methods to capture a range of usage styles: <ul>
22 *
23 * <li>The computation performed by a stage may be expressed as a
24 * Function, Consumer, or Runnable (using methods with names including
25 * <em>apply</em>, <em>accept</em>, or <em>run</em>, respectively)
26 * depending on whether it requires arguments and/or produces results.
27 * For example, {@code stage.thenApply(x -> square(x)).thenAccept(x ->
28 * System.out.print(x)).thenRun(() -> System.out.println())}. An
29 * additional form (<em>compose</em>) applies functions of stages
30 * themselves, rather than their results. </li>
31 *
32 * <li> One stage's execution may be triggered by completion of a
33 * single stage, or both of two stages, or either of two stages.
34 * Dependencies on a single stage are arranged using methods with
35 * prefix <em>then</em>. Those triggered by completion of
36 * <em>both</em> of two stages may <em>combine</em> their results or
37 * effects, using correspondingly named methods. Those triggered by
38 * <em>either</em> of two stages make no guarantees about which of the
39 * results or effects are used for the dependent stage's
40 * computation.</li>
41 *
42 * <li> Dependencies among stages control the triggering of
43 * computations, but do not otherwise guarantee any particular
44 * ordering. Additionally, execution of a new stage's computations may
45 * be arranged in any of three ways: default execution, default
46 * asynchronous execution (using methods with suffix <em>async</em>
47 * that employ the stage's default asynchronous execution facility),
48 * or custom (via a supplied {@link Executor}). The execution
49 * properties of default and async modes are specified by
50 * CompletionStage implementations, not this interface. Methods with
51 * explicit Executor arguments may have arbitrary execution
52 * properties, and might not even support concurrent execution, but
53 * are arranged for processing in a way that accommodates asynchrony.
54 *
55 * <li> Two method forms support processing whether the triggering
56 * stage completed normally or exceptionally: Method {@link
57 * #whenComplete whenComplete} allows injection of an action
58 * regardless of outcome, otherwise preserving the outcome in its
59 * completion. Method {@link #handle handle} additionally allows the
60 * stage to compute a replacement result that may enable further
61 * processing by other dependent stages. In all other cases, if a
62 * stage's computation terminates abruptly with an (unchecked)
63 * exception or error, then all dependent stages requiring its
64 * completion complete exceptionally as well, with a {@link
65 * CompletionException} holding the exception as its cause. If a
66 * stage is dependent on <em>both</em> of two stages, and both
67 * complete exceptionally, then the CompletionException may correspond
68 * to either one of these exceptions. If a stage is dependent on
69 * <em>either</em> of two others, and only one of them completes
70 * exceptionally, no guarantees are made about whether the dependent
71 * stage completes normally or exceptionally. In the case of method
72 * {@code whenComplete}, when the supplied action itself encounters an
73 * exception, then the stage exceptionally completes with this
74 * exception if not already completed exceptionally.</li>
75 *
76 * </ul>
77 *
78 * <p>All methods adhere to the above triggering, execution, and
79 * exceptional completion specifications (which are not repeated in
80 * individual method specifications). Additionally, while arguments
81 * used to pass a completion result (that is, for parameters of type
82 * {@code T}) for methods accepting them may be null, passing a null
83 * value for any other parameter will result in a {@link
84 * NullPointerException} being thrown.
85 *
86 * <p>This interface does not define methods for initially creating,
87 * forcibly completing normally or exceptionally, probing completion
88 * status or results, or awaiting completion of a stage.
89 * Implementations of CompletionStage may provide means of achieving
90 * such effects, as appropriate. Method {@link #toCompletableFuture}
91 * enables interoperability among different implementations of this
92 * interface by providing a common conversion type.
93 *
94 * @author Doug Lea
95 * @since 1.8
96 */
97 public interface CompletionStage<T> {
98
99 /**
100 * Returns a new CompletionStage that, when this stage completes
101 * normally, is executed with this stage's result as the argument
102 * to the supplied function.
103 *
104 * See the {@link CompletionStage} documentation for rules
105 * covering exceptional completion.
106 *
107 * @param fn the function to use to compute the value of
108 * the returned CompletionStage
109 * @return the new CompletionStage
110 */
111 public <U> CompletionStage<U> thenApply(Function<? super T,? extends U> fn);
112
113 /**
114 * Returns a new CompletionStage that, when this stage completes
115 * normally, is executed using this stage's default asynchronous
116 * execution facility, with this stage's result as the argument to
117 * the supplied function.
118 *
119 * See the {@link CompletionStage} documentation for rules
120 * covering exceptional completion.
121 *
122 * @param fn the function to use to compute the value of
123 * the returned CompletionStage
124 * @return the new CompletionStage
125 */
126 public <U> CompletionStage<U> thenApplyAsync
127 (Function<? super T,? extends U> fn);
128
129 /**
130 * Returns a new CompletionStage that, when this stage completes
131 * normally, is executed using the supplied Executor, with this
132 * stage's result as the argument to the supplied function.
133 *
134 * See the {@link CompletionStage} documentation for rules
135 * covering exceptional completion.
136 *
137 * @param fn the function to use to compute the value of
138 * the returned CompletionStage
139 * @param executor the executor to use for asynchronous execution
140 * @return the new CompletionStage
141 */
142 public <U> CompletionStage<U> thenApplyAsync
143 (Function<? super T,? extends U> fn,
144 Executor executor);
145
146 /**
147 * Returns a new CompletionStage that, when this stage completes
148 * normally, is executed with this stage's result as the argument
149 * to the supplied action.
150 *
151 * See the {@link CompletionStage} documentation for rules
152 * covering exceptional completion.
153 *
154 * @param action the action to perform before completing the
155 * returned CompletionStage
156 * @return the new CompletionStage
157 */
158 public CompletionStage<Void> thenAccept(Consumer<? super T> action);
159
160 /**
161 * Returns a new CompletionStage that, when this stage completes
162 * normally, is executed using this stage's default asynchronous
163 * execution facility, with this stage's result as the argument to
164 * the supplied action.
165 *
166 * See the {@link CompletionStage} documentation for rules
167 * covering exceptional completion.
168 *
169 * @param action the action to perform before completing the
170 * returned CompletionStage
171 * @return the new CompletionStage
172 */
173 public CompletionStage<Void> thenAcceptAsync(Consumer<? super T> action);
174
175 /**
176 * Returns a new CompletionStage that, when this stage completes
177 * normally, is executed using the supplied Executor, with this
178 * stage's result as the argument to the supplied action.
179 *
180 * See the {@link CompletionStage} documentation for rules
181 * covering exceptional completion.
182 *
183 * @param action the action to perform before completing the
184 * returned CompletionStage
185 * @param executor the executor to use for asynchronous execution
186 * @return the new CompletionStage
187 */
188 public CompletionStage<Void> thenAcceptAsync(Consumer<? super T> action,
189 Executor executor);
190 /**
191 * Returns a new CompletionStage that, when this stage completes
192 * normally, executes the given action.
193 *
194 * See the {@link CompletionStage} documentation for rules
195 * covering exceptional completion.
196 *
197 * @param action the action to perform before completing the
198 * returned CompletionStage
199 * @return the new CompletionStage
200 */
201 public CompletionStage<Void> thenRun(Runnable action);
202
203 /**
204 * Returns a new CompletionStage that, when this stage completes
205 * normally, executes the given action using this stage's default
206 * asynchronous execution facility.
207 *
208 * See the {@link CompletionStage} documentation for rules
209 * covering exceptional completion.
210 *
211 * @param action the action to perform before completing the
212 * returned CompletionStage
213 * @return the new CompletionStage
214 */
215 public CompletionStage<Void> thenRunAsync(Runnable action);
216
217 /**
218 * Returns a new CompletionStage that, when this stage completes
219 * normally, executes the given action using the supplied Executor.
220 *
221 * See the {@link CompletionStage} documentation for rules
222 * covering exceptional completion.
223 *
224 * @param action the action to perform before completing the
225 * returned CompletionStage
226 * @param executor the executor to use for asynchronous execution
227 * @return the new CompletionStage
228 */
229 public CompletionStage<Void> thenRunAsync(Runnable action,
230 Executor executor);
231
232 /**
233 * Returns a new CompletionStage that, when this and the other
234 * given stage both complete normally, is executed with the two
235 * results as arguments to the supplied function.
236 *
237 * See the {@link CompletionStage} documentation for rules
238 * covering exceptional completion.
239 *
240 * @param other the other CompletionStage
241 * @param fn the function to use to compute the value of
242 * the returned CompletionStage
243 * @return the new CompletionStage
244 */
245 public <U,V> CompletionStage<V> thenCombine
246 (CompletionStage<? extends U> other,
247 BiFunction<? super T,? super U,? extends V> fn);
248
249 /**
250 * Returns a new CompletionStage that, when this and the other
251 * given stage complete normally, is executed using this stage's
252 * default asynchronous execution facility, with the two results
253 * as arguments to the supplied function.
254 *
255 * See the {@link CompletionStage} documentation for rules
256 * covering exceptional completion.
257 *
258 * @param other the other CompletionStage
259 * @param fn the function to use to compute the value of
260 * the returned CompletionStage
261 * @return the new CompletionStage
262 */
263 public <U,V> CompletionStage<V> thenCombineAsync
264 (CompletionStage<? extends U> other,
265 BiFunction<? super T,? super U,? extends V> fn);
266
267 /**
268 * Returns a new CompletionStage that, when this and the other
269 * given stage complete normally, is executed using the supplied
270 * executor, with the two results as arguments to the supplied
271 * function.
272 *
273 * See the {@link CompletionStage} documentation for rules
274 * covering exceptional completion.
275 *
276 * @param other the other CompletionStage
277 * @param fn the function to use to compute the value of
278 * the returned CompletionStage
279 * @param executor the executor to use for asynchronous execution
280 * @return the new CompletionStage
281 */
282 public <U,V> CompletionStage<V> thenCombineAsync
283 (CompletionStage<? extends U> other,
284 BiFunction<? super T,? super U,? extends V> fn,
285 Executor executor);
286
287 /**
288 * Returns a new CompletionStage that, when this and the other
289 * given stage both complete normally, is executed with the two
290 * results as arguments to the supplied action.
291 *
292 * See the {@link CompletionStage} documentation for rules
293 * covering exceptional completion.
294 *
295 * @param other the other CompletionStage
296 * @param action the action to perform before completing the
297 * returned CompletionStage
298 * @return the new CompletionStage
299 */
300 public <U> CompletionStage<Void> thenAcceptBoth
301 (CompletionStage<? extends U> other,
302 BiConsumer<? super T, ? super U> action);
303
304 /**
305 * Returns a new CompletionStage that, when this and the other
306 * given stage complete normally, is executed using this stage's
307 * default asynchronous execution facility, with the two results
308 * as arguments to the supplied action.
309 *
310 * @param other the other CompletionStage
311 * @param action the action to perform before completing the
312 * returned CompletionStage
313 * @return the new CompletionStage
314 */
315 public <U> CompletionStage<Void> thenAcceptBothAsync
316 (CompletionStage<? extends U> other,
317 BiConsumer<? super T, ? super U> action);
318
319 /**
320 * Returns a new CompletionStage that, when this and the other
321 * given stage complete normally, is executed using the supplied
322 * executor, with the two results as arguments to the supplied
323 * function.
324 *
325 * @param other the other CompletionStage
326 * @param action the action to perform before completing the
327 * returned CompletionStage
328 * @param executor the executor to use for asynchronous execution
329 * @return the new CompletionStage
330 */
331 public <U> CompletionStage<Void> thenAcceptBothAsync
332 (CompletionStage<? extends U> other,
333 BiConsumer<? super T, ? super U> action,
334 Executor executor);
335
336 /**
337 * Returns a new CompletionStage that, when this and the other
338 * given stage both complete normally, executes the given action.
339 *
340 * See the {@link CompletionStage} documentation for rules
341 * covering exceptional completion.
342 *
343 * @param other the other CompletionStage
344 * @param action the action to perform before completing the
345 * returned CompletionStage
346 * @return the new CompletionStage
347 */
348 public CompletionStage<Void> runAfterBoth(CompletionStage<?> other,
349 Runnable action);
350 /**
351 * Returns a new CompletionStage that, when this and the other
352 * given stage complete normally, executes the given action using
353 * this stage's default asynchronous execution facility.
354 *
355 * See the {@link CompletionStage} documentation for rules
356 * covering exceptional completion.
357 *
358 * @param other the other CompletionStage
359 * @param action the action to perform before completing the
360 * returned CompletionStage
361 * @return the new CompletionStage
362 */
363 public CompletionStage<Void> runAfterBothAsync(CompletionStage<?> other,
364 Runnable action);
365
366 /**
367 * Returns a new CompletionStage that, when this and the other
368 * given stage complete normally, executes the given action using
369 * the supplied executor
370 *
371 * See the {@link CompletionStage} documentation for rules
372 * covering exceptional completion.
373 *
374 * @param other the other CompletionStage
375 * @param action the action to perform before completing the
376 * returned CompletionStage
377 * @param executor the executor to use for asynchronous execution
378 * @return the new CompletionStage
379 */
380 public CompletionStage<Void> runAfterBothAsync(CompletionStage<?> other,
381 Runnable action,
382 Executor executor);
383 /**
384 * Returns a new CompletionStage that, when either this or the
385 * other given stage complete normally, is executed with the
386 * corresponding result as argument to the supplied function.
387 *
388 * See the {@link CompletionStage} documentation for rules
389 * covering exceptional completion.
390 *
391 * @param other the other CompletionStage
392 * @param fn the function to use to compute the value of
393 * the returned CompletionStage
394 * @return the new CompletionStage
395 */
396 public <U> CompletionStage<U> applyToEither
397 (CompletionStage<? extends T> other,
398 Function<? super T, U> fn);
399
400 /**
401 * Returns a new CompletionStage that, when either this or the
402 * other given stage complete normally, is executed using this
403 * stage's default asynchronous execution facility, with the
404 * corresponding result as argument to the supplied function.
405 *
406 * See the {@link CompletionStage} documentation for rules
407 * covering exceptional completion.
408 *
409 * @param other the other CompletionStage
410 * @param fn the function to use to compute the value of
411 * the returned CompletionStage
412 * @return the new CompletionStage
413 */
414 public <U> CompletionStage<U> applyToEitherAsync
415 (CompletionStage<? extends T> other,
416 Function<? super T, U> fn);
417
418 /**
419 * Returns a new CompletionStage that, when either this or the
420 * other given stage complete normally, is executed using the
421 * supplied executor, with the corresponding result as argument to
422 * the supplied function.
423 *
424 * See the {@link CompletionStage} documentation for rules
425 * covering exceptional completion.
426 *
427 * @param other the other CompletionStage
428 * @param fn the function to use to compute the value of
429 * the returned CompletionStage
430 * @param executor the executor to use for asynchronous execution
431 * @return the new CompletionStage
432 */
433 public <U> CompletionStage<U> applyToEitherAsync
434 (CompletionStage<? extends T> other,
435 Function<? super T, U> fn,
436 Executor executor);
437
438 /**
439 * Returns a new CompletionStage that, when either this or the
440 * other given stage complete normally, is executed with the
441 * corresponding result as argument to the supplied action.
442 *
443 * See the {@link CompletionStage} documentation for rules
444 * covering exceptional completion.
445 *
446 * @param other the other CompletionStage
447 * @param action the action to perform before completing the
448 * returned CompletionStage
449 * @return the new CompletionStage
450 */
451 public CompletionStage<Void> acceptEither
452 (CompletionStage<? extends T> other,
453 Consumer<? super T> action);
454
455 /**
456 * Returns a new CompletionStage that, when either this or the
457 * other given stage complete normally, is executed using this
458 * stage's default asynchronous execution facility, with the
459 * corresponding result as argument to the supplied action.
460 *
461 * See the {@link CompletionStage} documentation for rules
462 * covering exceptional completion.
463 *
464 * @param other the other CompletionStage
465 * @param action the action to perform before completing the
466 * returned CompletionStage
467 * @return the new CompletionStage
468 */
469 public CompletionStage<Void> acceptEitherAsync
470 (CompletionStage<? extends T> other,
471 Consumer<? super T> action);
472
473 /**
474 * Returns a new CompletionStage that, when either this or the
475 * other given stage complete normally, is executed using the
476 * supplied executor, with the corresponding result as argument to
477 * the supplied function.
478 *
479 * See the {@link CompletionStage} documentation for rules
480 * covering exceptional completion.
481 *
482 * @param other the other CompletionStage
483 * @param action the action to perform before completing the
484 * returned CompletionStage
485 * @param executor the executor to use for asynchronous execution
486 * @return the new CompletionStage
487 */
488 public CompletionStage<Void> acceptEitherAsync
489 (CompletionStage<? extends T> other,
490 Consumer<? super T> action,
491 Executor executor);
492
493 /**
494 * Returns a new CompletionStage that, when either this or the
495 * other given stage complete normally, executes the given action.
496 *
497 * See the {@link CompletionStage} documentation for rules
498 * covering exceptional completion.
499 *
500 * @param other the other CompletionStage
501 * @param action the action to perform before completing the
502 * returned CompletionStage
503 * @return the new CompletionStage
504 */
505 public CompletionStage<Void> runAfterEither(CompletionStage<?> other,
506 Runnable action);
507
508 /**
509 * Returns a new CompletionStage that, when either this or the
510 * other given stage complete normally, executes the given action
511 * using this stage's default asynchronous execution facility.
512 *
513 * See the {@link CompletionStage} documentation for rules
514 * covering exceptional completion.
515 *
516 * @param other the other CompletionStage
517 * @param action the action to perform before completing the
518 * returned CompletionStage
519 * @return the new CompletionStage
520 */
521 public CompletionStage<Void> runAfterEitherAsync
522 (CompletionStage<?> other,
523 Runnable action);
524
525 /**
526 * Returns a new CompletionStage that, when either this or the
527 * other given stage complete normally, executes the given action
528 * using supplied executor.
529 *
530 * See the {@link CompletionStage} documentation for rules
531 * covering exceptional completion.
532 *
533 * @param other the other CompletionStage
534 * @param action the action to perform before completing the
535 * returned CompletionStage
536 * @param executor the executor to use for asynchronous execution
537 * @return the new CompletionStage
538 */
539 public CompletionStage<Void> runAfterEitherAsync
540 (CompletionStage<?> other,
541 Runnable action,
542 Executor executor);
543
544 /**
545 * Returns a new CompletionStage that, when this stage completes
546 * normally, is executed with this stage as the argument
547 * to the supplied function.
548 *
549 * See the {@link CompletionStage} documentation for rules
550 * covering exceptional completion.
551 *
552 * @param fn the function returning a new CompletionStage
553 * @return the CompletionStage
554 */
555 public <U> CompletionStage<U> thenCompose
556 (Function<? super T, ? extends CompletionStage<U>> fn);
557
558 /**
559 * Returns a new CompletionStage that, when this stage completes
560 * normally, is executed using this stage's default asynchronous
561 * execution facility, with this stage as the argument to the
562 * supplied function.
563 *
564 * See the {@link CompletionStage} documentation for rules
565 * covering exceptional completion.
566 *
567 * @param fn the function returning a new CompletionStage
568 * @return the CompletionStage
569 */
570 public <U> CompletionStage<U> thenComposeAsync
571 (Function<? super T, ? extends CompletionStage<U>> fn);
572
573 /**
574 * Returns a new CompletionStage that, when this stage completes
575 * normally, is executed using the supplied Executor, with this
576 * stage's result as the argument to the supplied function.
577 *
578 * See the {@link CompletionStage} documentation for rules
579 * covering exceptional completion.
580 *
581 * @param fn the function returning a new CompletionStage
582 * @param executor the executor to use for asynchronous execution
583 * @return the CompletionStage
584 */
585 public <U> CompletionStage<U> thenComposeAsync
586 (Function<? super T, ? extends CompletionStage<U>> fn,
587 Executor executor);
588
589 /**
590 * Returns a new CompletionStage that, when this stage completes
591 * exceptionally, is executed with this stage's exception as the
592 * argument to the supplied function. Otherwise, if this stage
593 * completes normally, then the returned stage also completes
594 * normally with the same value.
595 *
596 * @param fn the function to use to compute the value of the
597 * returned CompletionStage if this CompletionStage completed
598 * exceptionally
599 * @return the new CompletionStage
600 */
601 public CompletionStage<T> exceptionally
602 (Function<Throwable, ? extends T> fn);
603
604 /**
605 * Returns a new CompletionStage with the same result or exception
606 * as this stage, and when this stage completes, executes the
607 * given action with the result (or {@code null} if none) and the
608 * exception (or {@code null} if none) of this stage.
609 *
610 * @param action the action to perform
611 */
612 public CompletionStage<T> whenComplete
613 (BiConsumer<? super T, ? super Throwable> action);
614
615 /**
616 * Returns a new CompletionStage with the same result or exception
617 * as this stage, and when this stage completes, executes the
618 * given action executes the given action using this stage's
619 * default asynchronous execution facility, with the result (or
620 * {@code null} if none) and the exception (or {@code null} if
621 * none) of this stage as arguments.
622 *
623 * @param action the action to perform
624 */
625 public CompletionStage<T> whenCompleteAsync
626 (BiConsumer<? super T, ? super Throwable> action);
627
628 /**
629 * Returns a new CompletionStage with the same result or exception
630 * as this stage, and when this stage completes, executes using
631 * the supplied Executor, the given action with the result (or
632 * {@code null} if none) and the exception (or {@code null} if
633 * none) of this stage as arguments.
634 *
635 * @param action the action to perform
636 */
637 public CompletionStage<T> whenCompleteAsync
638 (BiConsumer<? super T, ? super Throwable> action,
639 Executor executor);
640
641 /**
642 * Returns a new CompletionStage that, when this stage completes
643 * either normally or exceptionally, is executed with this stage's
644 * result and exception as arguments to the supplied function.
645 * The given function is invoked with the result (or {@code null}
646 * if none) and the exception (or {@code null} if none) of this
647 * stage when complete as arguments.
648 *
649 * @param fn the function to use to compute the value of the
650 * returned CompletionStage
651 * @return the new CompletionStage
652 */
653 public <U> CompletionStage<U> handle
654 (BiFunction<? super T, Throwable, ? extends U> fn);
655
656 /**
657 * Returns a new CompletionStage that, when this stage completes
658 * either normally or exceptionally, is executed using this stage's
659 * default asynchronous execution facility, with this stage's
660 * result and exception as arguments to the supplied function.
661 * The given function is invoked with the result (or {@code null}
662 * if none) and the exception (or {@code null} if none) of this
663 * stage when complete as arguments.
664 *
665 * @param fn the function to use to compute the value of the
666 * returned CompletionStage
667 * @return the new CompletionStage
668 */
669 public <U> CompletionStage<U> handleAsync
670 (BiFunction<? super T, Throwable, ? extends U> fn);
671
672 /**
673 * Returns a new CompletionStage that, when this stage completes
674 * either normally or exceptionally, is executed using the
675 * supplied executor, with this stage's result and exception as
676 * arguments to the supplied function. The given function is
677 * invoked with the result (or {@code null} if none) and the
678 * exception (or {@code null} if none) of this stage when complete
679 * as arguments.
680 *
681 * @param fn the function to use to compute the value of the
682 * returned CompletionStage
683 * @return the new CompletionStage
684 */
685 public <U> CompletionStage<U> handleAsync
686 (BiFunction<? super T, Throwable, ? extends U> fn,
687 Executor executor);
688
689 /**
690 * Returns a {@link CompletableFuture} maintaining the same
691 * completion properties as this stage. If this stage is already a
692 * CompletableFuture, this method may return this stage itself.
693 * Otherwise, invocation of this method may be equivalent in
694 * effect to {@code thenApply(x -> x)}, but returning an instance
695 * of type {@code CompletableFuture}. A CompletionStage
696 * implementation that does not choose to interoperate with others
697 * may throw {@code UnsupportedOperationException}.
698 *
699 * @return the CompletableFuture
700 */
701 public CompletableFuture<T> toCompletableFuture();
702
703 }