Skip to content

Commit

Permalink
+ using work stealing pool
Browse files Browse the repository at this point in the history
  • Loading branch information
q3769 committed May 11, 2024
1 parent 41b3a55 commit 8b391a9
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main/java/conottle/Conottle.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ public final class Conottle implements ClientTaskExecutor, AutoCloseable {

@Builder
private Conottle(int maxClientsPermitted, int maxParallelismPerClient, ExecutorService workerExecutorService) {
maxClientsPermitted = requireNonNegativeOrThrow(maxClientsPermitted);
this.activeThrottlingExecutors = new ConcurrentHashMap<>(maxClientsPermitted);
this.clientTotalThrottle = new Semaphore(maxClientsPermitted);
this.activeThrottlingExecutors = new ConcurrentHashMap<>(requireNonNegativeOrThrow(maxClientsPermitted));
this.clientTotalThrottle = new Semaphore(requireNonNegativeOrThrow(maxClientsPermitted));
this.maxParallelismPerClient = requireNonNegativeOrThrow(maxParallelismPerClient);
this.workerExecutorService =
workerExecutorService == null ? Executors.newFixedThreadPool(DEFAULT_MAX) : workerExecutorService;
workerExecutorService == null ? Executors.newWorkStealingPool(DEFAULT_MAX) : workerExecutorService;
}

private static int requireNonNegativeOrThrow(int value) {
Expand Down

0 comments on commit 8b391a9

Please sign in to comment.