@@ -48,8 +48,8 @@ public final class Conottle implements ClientTaskExecutor, AutoCloseable {
4848 Math .max (16 , Runtime .getRuntime ().availableProcessors ());
4949 private static final Logger logger = Logger .instance ();
5050 private final ExecutorService adminExecutorService = Executors .newSingleThreadExecutor ();
51- private final ConcurrentMap <Object , TaskThrottlingExecutorService > activeThrottlingExecutors ;
52- private final ObjectPool <TaskThrottlingExecutorService > throttlingExecutorPool ;
51+ private final ConcurrentMap <Object , PendingWorkAwareExecutor > activeThrottlingExecutors ;
52+ private final ObjectPool <PendingWorkAwareExecutor > throttlingExecutorPool ;
5353
5454 private Conottle (@ NonNull Builder builder ) {
5555 this .activeThrottlingExecutors = new ConcurrentHashMap <>(builder .maxTotalClientsInParallel );
@@ -60,8 +60,8 @@ private Conottle(@NonNull Builder builder) {
6060 }
6161
6262 @ NonNull
63- private static GenericObjectPoolConfig <TaskThrottlingExecutorService > getThrottlingExecutorPoolConfig (int poolSizeMaxTotal ) {
64- GenericObjectPoolConfig <TaskThrottlingExecutorService > throttlingExecutorPoolConfig =
63+ private static GenericObjectPoolConfig <PendingWorkAwareExecutor > getThrottlingExecutorPoolConfig (int poolSizeMaxTotal ) {
64+ GenericObjectPoolConfig <PendingWorkAwareExecutor > throttlingExecutorPoolConfig =
6565 new GenericObjectPoolConfig <>();
6666 throttlingExecutorPoolConfig .setMaxTotal (poolSizeMaxTotal );
6767 return throttlingExecutorPoolConfig ;
@@ -78,7 +78,7 @@ public CompletableFuture<Void> execute(@NonNull Runnable command, @NonNull Objec
7878 public <V > CompletableFuture <V > submit (@ NonNull Callable <V > task , @ NonNull Object clientId ) {
7979 CompletableFutureHolder <V > taskCompletableFutureHolder = new CompletableFutureHolder <>();
8080 activeThrottlingExecutors .compute (clientId , (k , presentExecutor ) -> {
81- TaskThrottlingExecutorService executor = (presentExecutor == null ) ? borrowFromPool () : presentExecutor ;
81+ PendingWorkAwareExecutor executor = (presentExecutor == null ) ? borrowFromPool () : presentExecutor ;
8282 taskCompletableFutureHolder .setCompletableFuture (executor .submit (task ));
8383 return executor ;
8484 });
@@ -104,15 +104,15 @@ int countActiveExecutors() {
104104 return activeThrottlingExecutors .size ();
105105 }
106106
107- private TaskThrottlingExecutorService borrowFromPool () {
107+ private PendingWorkAwareExecutor borrowFromPool () {
108108 try {
109109 return throttlingExecutorPool .borrowObject ();
110110 } catch (Exception e ) {
111111 throw new IllegalStateException ("Failed to borrow executor from pool " + throttlingExecutorPool , e );
112112 }
113113 }
114114
115- private void returnToPool (TaskThrottlingExecutorService throttlingExecutor ) {
115+ private void returnToPool (PendingWorkAwareExecutor throttlingExecutor ) {
116116 adminExecutorService .submit (() -> {
117117 try {
118118 throttlingExecutorPool .returnObject (throttlingExecutor );
0 commit comments