26.3.4 同時非同期操作の処理

グラフ・サーバー(PGX)によって提供されるPgxSession#runConcurrently APIを使用すると、非同期APIのサプライヤのリストを送信して、PGXサーバーで同時に実行できます。

たとえば:

import oracle.pgx.api.*;

    Supplier<PgxFuture<?>> asyncRequest1 = () -> session.readGraphWithPropertiesAsync(...);
    Supplier<PgxFuture<?>> asyncRequest2 = () -> session.getAvailableSnapshotsAsync(...);

    List<Supplier<PgxFuture<?>>> supplierList = Arrays.asList(asyncRequest1, asyncRequest2);

    //executing the async requests with the enabled optimization feature
    List<?> results = session.runConcurrently(supplierList);

    //the supplied requests are mapped to their results and orderly collected
    PgxGraph graph = (PgxGraph) results.get(0);
    Deque<GraphMetaData> metaData = (Deque<GraphMetaData>) results.get(1);