public CompletableFuture add()

in src/main/java/com/spotify/futures/ConcurrencyReducer.java [78:88]


  public CompletableFuture<T> add(final Callable<? extends CompletionStage<T>> callable) {
    requireNonNull(callable);
    final CompletableFuture<T> response = new CompletableFuture<>();
    final Job<T> job = new Job<>(callable, response);
    if (!queue.offer(job)) {
      final String message = "Queue size has reached capacity: " + maxQueueSize;
      return CompletableFutures.exceptionallyCompletedFuture(new CapacityReachedException(message));
    }
    pump();
    return response;
  }