クラス
java.util.concurrent.CompletableFutureの使用
CompletableFutureを使用するパッケージ
パッケージ
説明
Javaプログラミング言語の設計にあたり基本的なクラスを提供します。
HTTPクライアントおよびWebSocket API
並行プログラミングでよく使用されるユーティリティ・クラスです。
-
java.langでのCompletableFutureの使用
CompletableFutureを返すjava.langのメソッド -
java.net.httpでのCompletableFutureの使用
CompletableFutureを返すjava.net.httpのメソッド修飾子と型メソッド説明WebSocket.Builder.buildAsync(URI uri, WebSocket.Listener listener)
指定されたURI
に接続され、指定されたListener
に関連付けられたWebSocket
を構築します。abstract <T> CompletableFuture<HttpResponse<T>>
HttpClient.sendAsync(HttpRequest request, HttpResponse.BodyHandler<T> responseBodyHandler)
指定されたレスポンス本文ハンドラとともに、このクライアントを使用して、指定されたリクエストを非同期に送信します。abstract <T> CompletableFuture<HttpResponse<T>>
HttpClient.sendAsync(HttpRequest request, HttpResponse.BodyHandler<T> responseBodyHandler, HttpResponse.PushPromiseHandler<T> pushPromiseHandler)
指定されたレスポンス本文ハンドラとともにこのクライアントを使用して、指定されたリクエストを非同期に送信し、プッシュ・プロミス・ハンドラをプッシュします。WebSocket.sendBinary(ByteBuffer data, boolean last)
指定されたバッファのバイトとともにバイナリ・データを送信します。指定されたステータス・コードおよび理由でCloseメッセージを送信することで、このWebSocket出力の正しいクローズを開始します。WebSocket.sendPing(ByteBuffer message)
指定されたバッファのバイトとともにpingメッセージを送信します。WebSocket.sendPong(ByteBuffer message)
指定されたバッファからバイトを含むPongメッセージを送信します。WebSocket.sendText(CharSequence data, boolean last)
指定された文字シーケンスの文字を含むテキスト・データを送信します。型CompletableFutureの型引数を持つjava.net.httpのメソッド・パラメータ修飾子と型メソッド説明void
HttpResponse.PushPromiseHandler.applyPushPromise(HttpRequest initiatingRequest, HttpRequest pushPromiseRequest, Function<HttpResponse.BodyHandler<T>,CompletableFuture<HttpResponse<T>>> acceptor)
受信プッシュ・プロミスの通知。static <T> HttpResponse.PushPromiseHandler<T>
HttpResponse.PushPromiseHandler.of(Function<HttpRequest,HttpResponse.BodyHandler<T>> pushPromiseHandler, ConcurrentMap<HttpRequest,CompletableFuture<HttpResponse<T>>> pushPromisesMap)
指定されたマップに、プッシュ・プロミスおよびそのレスポンスを累積する、プッシュ・プロミス・ハンドラを返します。 -
java.util.concurrentでのCompletableFutureの使用
修飾子と型メソッド説明CompletableFuture.acceptEither(CompletionStage<? extends T> other, Consumer<? super T> action)
CompletableFuture.acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action)
CompletableFuture.acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor)
static CompletableFuture<Void>
CompletableFuture.allOf(CompletableFuture<?>... cfs)
指定されたすべてのCompletableFutureが完了したときに完了する新しいCompletableFutureを返します。static CompletableFuture<Object>
CompletableFuture.anyOf(CompletableFuture<?>... cfs)
指定されたいずれかのCompletableFutureが完了したときに同じ結果で完了する新しいCompletableFutureを返します。<U> CompletableFuture<U>
CompletableFuture.applyToEither(CompletionStage<? extends T> other, Function<? super T,U> fn)
<U> CompletableFuture<U>
CompletableFuture.applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T,U> fn)
<U> CompletableFuture<U>
CompletableFuture.applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T,U> fn, Executor executor)
CompletableFuture.completeAsync(Supplier<? extends T> supplier)
このCompletableFutureを、デフォルトExecutorを使用して非同期タスクから呼び出された、指定されたSupplier関数の結果で完了させます。CompletableFuture.completeAsync(Supplier<? extends T> supplier, Executor executor)
指定されたExecutorを使用して非同期タスクから呼び出された、指定されたSupplier関数の結果でこのCompletableFutureを完了します。static <U> CompletableFuture<U>
CompletableFuture.completedFuture(U value)
指定された値ですでに完了している新しいCompletableFutureを返します。CompletableFuture.completeOnTimeout(T value, long timeout, TimeUnit unit)
指定されたタイムアウト前に完了していない場合は、このCompletableFutureを指定された値で完了します。指定したコンシューマ関数を使用して、公開されたすべてのアイテムを処理します。CompletableFuture.copy()
正常に完了したときにこのCompletableFutureと同じ値で正常に完了する新しいCompletableFutureを返します。CompletableFuture.exceptionally(Function<Throwable,? extends T> fn)
static <U> CompletableFuture<U>
CompletableFuture.failedFuture(Throwable ex)
指定された例外を使ってすでに例外的に完了している新しいCompletableFutureを返します。<U> CompletableFuture<U>
CompletableFuture.handle(BiFunction<? super T,Throwable,? extends U> fn)
<U> CompletableFuture<U>
CompletableFuture.handleAsync(BiFunction<? super T,Throwable,? extends U> fn)
<U> CompletableFuture<U>
CompletableFuture.handleAsync(BiFunction<? super T,Throwable,? extends U> fn, Executor executor)
<U> CompletableFuture<U>
CompletableFuture.newIncompleteFuture()
CompletionStageメソッドによって返される型の新しいCompletableFutureを返します。例外的に、このCompletableFutureをTimeoutException
で完了します(指定されたタイムアウト前に完了していない場合)。CompletableFuture.runAfterBoth(CompletionStage<?> other, Runnable action)
CompletableFuture.runAfterBothAsync(CompletionStage<?> other, Runnable action)
CompletableFuture.runAfterBothAsync(CompletionStage<?> other, Runnable action, Executor executor)
CompletableFuture.runAfterEither(CompletionStage<?> other, Runnable action)
CompletableFuture.runAfterEitherAsync(CompletionStage<?> other, Runnable action)
CompletableFuture.runAfterEitherAsync(CompletionStage<?> other, Runnable action, Executor executor)
static CompletableFuture<Void>
ForkJoinPool.commonPool()
で実行されているタスクが指定されたアクションの実行後に非同期に完了する新しいCompletableFutureを返します。static CompletableFuture<Void>
指定されたexecutorで実行されているタスクが指定されたアクションの実行後に非同期に完了する新しいCompletableFutureを返します。static <U> CompletableFuture<U>
CompletableFuture.supplyAsync(Supplier<U> supplier)
ForkJoinPool.commonPool()
で実行されているタスクが指定されたサプライヤを呼び出して取得した値を使用して非同期的に完了する新しいCompletableFutureを返します。static <U> CompletableFuture<U>
CompletableFuture.supplyAsync(Supplier<U> supplier, Executor executor)
指定されたエグゼキュータで実行されているタスクが指定されたサプライヤを呼び出して取得した値を使用して非同期的に完了する新しいCompletableFutureを返します。CompletableFuture.thenAccept(Consumer<? super T> action)
CompletableFuture.thenAcceptAsync(Consumer<? super T> action)
CompletableFuture.thenAcceptAsync(Consumer<? super T> action, Executor executor)
<U> CompletableFuture<Void>
CompletableFuture.thenAcceptBoth(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action)
<U> CompletableFuture<Void>
CompletableFuture.thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action)
<U> CompletableFuture<Void>
CompletableFuture.thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action, Executor executor)
<U> CompletableFuture<U>
<U> CompletableFuture<U>
CompletableFuture.thenApplyAsync(Function<? super T,? extends U> fn)
<U> CompletableFuture<U>
CompletableFuture.thenApplyAsync(Function<? super T,? extends U> fn, Executor executor)
<U, V> CompletableFuture<V>
CompletableFuture.thenCombine(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)
<U, V> CompletableFuture<V>
CompletableFuture.thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)
<U, V> CompletableFuture<V>
CompletableFuture.thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn, Executor executor)
<U> CompletableFuture<U>
CompletableFuture.thenCompose(Function<? super T,? extends CompletionStage<U>> fn)
<U> CompletableFuture<U>
CompletableFuture.thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn)
<U> CompletableFuture<U>
CompletableFuture.thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn, Executor executor)
CompletableFuture.thenRunAsync(Runnable action)
CompletableFuture.thenRunAsync(Runnable action, Executor executor)
CompletableFuture.toCompletableFuture()
このCompletableFutureを返します。CompletionStage.toCompletableFuture()
このステージと同じ完了プロパティを保持するCompletableFuture
を返します。CompletableFuture.whenComplete(BiConsumer<? super T,? super Throwable> action)
CompletableFuture.whenCompleteAsync(BiConsumer<? super T,? super Throwable> action)
CompletableFuture.whenCompleteAsync(BiConsumer<? super T,? super Throwable> action, Executor executor)
型CompletableFutureのパラメータを持つjava.util.concurrentのメソッド修飾子と型メソッド説明static CompletableFuture<Void>
CompletableFuture.allOf(CompletableFuture<?>... cfs)
指定されたすべてのCompletableFutureが完了したときに完了する新しいCompletableFutureを返します。static CompletableFuture<Object>
CompletableFuture.anyOf(CompletableFuture<?>... cfs)
指定されたいずれかのCompletableFutureが完了したときに同じ結果で完了する新しいCompletableFutureを返します。