// Path: src/main/java/javascalautils/concurrent/PromiseCompanion.java
// public static <T> Promise<T> Promise() {
//   return Promise.apply();
// }


import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import static javascalautils.concurrent.PromiseCompanion.Promise;
    List<Future<T>> responses = new ArrayList<>();
    for (Callable<T> callable : callables) {
      responses.add(execute(callable));
    }
    return responses;
  }

  /**
   * Executes the provided {@link Runnable} on the internal executor. <br>
   * Any issues related to the internal executor are reported to the provided {@link Promise}
   *
   * @param promise The promise to fulfill once the work is finished
   * @param runnable The runnable to execute in the executor
   * @return The Future holding the response-to-be
   */
  private <T> Future<T> execute(Promise<T> promise, Runnable runnable) {
    try {
      executor.execute(runnable);
    } catch (RejectedExecutionException ex) {
      // could be rejected due to resource starvation, report a failure
      promise.failure(ex);
    }
    return promise.future();
  }

  /*
   * (non-Javadoc)
   *
   * @see javascalautils.concurrent.Executor#shutdown()
   */
// Path: src/main/java/javascalautils/concurrent/PromiseCompanion.java
// public static <T> Promise<T> Promise() {
//   return Promise.apply();
// }


// Path: src/main/java/javascalautils/concurrent/ExecutorImpl.java
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import static javascalautils.concurrent.PromiseCompanion.Promise;

    List<Future<T>> responses = new ArrayList<>();
    for (Callable<T> callable : callables) {
      responses.add(execute(callable));
    }
    return responses;
  }

  /**
   * Executes the provided {@link Runnable} on the internal executor. <br>
   * Any issues related to the internal executor are reported to the provided {@link Promise}
   *
   * @param promise The promise to fulfill once the work is finished
   * @param runnable The runnable to execute in the executor
   * @return The Future holding the response-to-be
   */
  private <T> Future<T> execute(Promise<T> promise, Runnable runnable) {
    try {
      executor.execute(runnable);
    } catch (RejectedExecutionException ex) {
      // could be rejected due to resource starvation, report a failure
      promise.failure(ex);
    }
    return promise.future();
  }

  /*
   * (non-Javadoc)
   *
   * @see javascalautils.concurrent.Executor#shutdown()
   */
  @Override