Skip to content

Commit

Permalink
Re-add removed methods to improve backwards compatibility (#50)
Browse files Browse the repository at this point in the history
Re-add removed methods to improve backwards compatibility
  • Loading branch information
spkrka committed Oct 21, 2021
1 parent d842600 commit 7dbdeed
Show file tree
Hide file tree
Showing 3 changed files with 453 additions and 53 deletions.
13 changes: 13 additions & 0 deletions src/main/java/com/spotify/futures/ConcurrencyLimiter.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;

import java.util.concurrent.ArrayBlockingQueue;
Expand Down Expand Up @@ -54,6 +55,18 @@ private ConcurrencyLimiter(final Executor executor, int maxConcurrency, int maxQ
this.limit = new Semaphore(maxConcurrency);
}

/**
* Create a {@code ConcurrencyLimiter} instance.
*
* @param maxConcurrency maximum number of futures in progress,
* @param maxQueueSize maximum number of jobs in queue. This is a soft bound and may be
* temporarily exceeded if add() is called concurrently.
* @return a new concurrency limiter
*/
public static <T> ConcurrencyLimiter<T> create(int maxConcurrency, int maxQueueSize) {
return new ConcurrencyLimiter<>(MoreExecutors.directExecutor(), maxConcurrency, maxQueueSize);
}

/**
* Create a {@code ConcurrencyLimiter} instance.
*
Expand Down
Loading

0 comments on commit 7dbdeed

Please sign in to comment.