クラス
java.util.concurrent.CompletableFutureの使用
| パッケージ | 説明 | 
|---|---|
| java.lang | Javaプログラミング言語の設計にあたり基本的なクラスを提供します。 | 
| java.net.http | HTTPクライアントおよびWebSocket API | 
| java.util.concurrent | 並行プログラミングでよく使用されるユーティリティ・クラスです。 | 
- 
java.langでのCompletableFutureの使用CompletableFutureを戻すjava.langのメソッド 修飾子と型 メソッド 説明 CompletableFuture<Process>Process. onExit()プロセス終了のためのCompletableFuture<Process>を返します。CompletableFuture<ProcessHandle>ProcessHandle. onExit()プロセスの終了のためのCompletableFuture<ProcessHandle>を返します。
- 
java.net.httpでのCompletableFutureの使用CompletableFutureを戻すjava.net.httpのメソッド 修飾子と型 メソッド 説明 CompletableFuture<WebSocket>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)指定されたレスポンス本文ハンドラとともにこのクライアントを使用して、指定されたリクエストを非同期に送信し、プッシュ・プロミス・ハンドラをプッシュします。CompletableFuture<WebSocket>WebSocket. sendBinary(ByteBuffer data, boolean last)指定されたバッファのバイトとともにバイナリ・データを送信します。CompletableFuture<WebSocket>WebSocket. sendClose(int statusCode, String reason)指定されたステータス・コードおよび理由でCloseメッセージを送信することで、このWebSocket出力の正しいクローズを開始します。CompletableFuture<WebSocket>WebSocket. sendPing(ByteBuffer message)指定されたバッファのバイトとともにpingメッセージを送信します。CompletableFuture<WebSocket>WebSocket. sendPong(ByteBuffer message)指定されたバッファからバイトを含むPongメッセージを送信します。CompletableFuture<WebSocket>WebSocket. sendText(CharSequence data, boolean last)指定された文字シーケンスの文字を含むテキスト・データを送信します。型CompletableFutureの型引数を持つjava.net.httpのメソッド・パラメータ 修飾子と型 メソッド 説明 voidHttpResponse.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を返すjava.util.concurrentのメソッド 修飾子と型 メソッド 説明 CompletableFuture<Void>CompletableFuture. acceptEither(CompletionStage<? extends T> other, Consumer<? super T> action)CompletableFuture<Void>CompletableFuture. acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action)CompletableFuture<Void>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を返します。CompletableFuture<T>CompletableFuture. completeAsync(Supplier<? extends T> supplier)このCompletableFutureを、デフォルトExecutorを使用して非同期タスクから呼び出された、指定されたSupplier関数の結果で完了させます。CompletableFuture<T>CompletableFuture. completeAsync(Supplier<? extends T> supplier, Executor executor)指定されたExecutorを使用して非同期タスクから呼び出された、指定されたSupplier関数の結果でこのCompletableFutureを完了します。static <U> CompletableFuture<U>CompletableFuture. completedFuture(U value)指定された値ですでに完了している新しいCompletableFutureを返します。CompletableFuture<T>CompletableFuture. completeOnTimeout(T value, long timeout, TimeUnit unit)指定されたタイムアウト前に完了していない場合は、このCompletableFutureを指定された値で完了します。CompletableFuture<Void>SubmissionPublisher. consume(Consumer<? super T> consumer)指定したコンシューマ関数を使用して、公開されたすべてのアイテムを処理します。CompletableFuture<T>CompletableFuture. copy()正常に完了したときにこのCompletableFutureと同じ値で正常に完了する新しいCompletableFutureを返します。static <U> CompletableFuture<U>CompletableFuture. failedFuture(Throwable ex)指定された例外を使ってすでに例外的に完了している新しいCompletableFutureを返します。<U> CompletableFuture<U>CompletableFuture. newIncompleteFuture()CompletionStageメソッドによって返される型の新しいCompletableFutureを返します。CompletableFuture<T>CompletableFuture. orTimeout(long timeout, TimeUnit unit)例外的に、このCompletableFutureをTimeoutExceptionで完了します(指定されたタイムアウト前に完了していない場合)。CompletableFuture<Void>CompletableFuture. runAfterBoth(CompletionStage<?> other, Runnable action)CompletableFuture<Void>CompletableFuture. runAfterBothAsync(CompletionStage<?> other, Runnable action)CompletableFuture<Void>CompletableFuture. runAfterBothAsync(CompletionStage<?> other, Runnable action, Executor executor)CompletableFuture<Void>CompletableFuture. runAfterEither(CompletionStage<?> other, Runnable action)CompletableFuture<Void>CompletableFuture. runAfterEitherAsync(CompletionStage<?> other, Runnable action)CompletableFuture<Void>CompletableFuture. runAfterEitherAsync(CompletionStage<?> other, Runnable action, Executor executor)static CompletableFuture<Void>CompletableFuture. runAsync(Runnable runnable)ForkJoinPool.commonPool()で実行されているタスクが指定されたアクションの実行後に非同期に完了する新しいCompletableFutureを返します。static CompletableFuture<Void>CompletableFuture. runAsync(Runnable runnable, Executor executor)指定された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<Void>CompletableFuture. thenAccept(Consumer<? super T> action)CompletableFuture<Void>CompletableFuture. thenAcceptAsync(Consumer<? super T> action)CompletableFuture<Void>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)CompletableFuture<Void>CompletableFuture. thenRun(Runnable action)CompletableFuture<Void>CompletableFuture. thenRunAsync(Runnable action)CompletableFuture<Void>CompletableFuture. thenRunAsync(Runnable action, Executor executor)CompletableFuture<T>CompletableFuture. toCompletableFuture()このCompletableFutureを返します。CompletableFuture<T>CompletionStage. toCompletableFuture()このステージと同じ完了プロパティを保持するCompletableFutureを返します。CompletableFuture型のパラメータを持つjava.util.concurrentのメソッド 修飾子と型 メソッド 説明 static CompletableFuture<Void>CompletableFuture. allOf(CompletableFuture<?>... cfs)指定されたすべてのCompletableFutureが完了したときに完了する新しいCompletableFutureを返します。static CompletableFuture<Object>CompletableFuture. anyOf(CompletableFuture<?>... cfs)指定されたいずれかのCompletableFutureが完了したときに同じ結果で完了する新しいCompletableFutureを返します。