File tree Expand file tree Collapse file tree 3 files changed +12
-10
lines changed Expand file tree Collapse file tree 3 files changed +12
-10
lines changed Original file line number Diff line number Diff line change 3030
3131 <groupId >io.github.q3769</groupId >
3232 <artifactId >conottle</artifactId >
33- <version >11.0.2 </version >
33+ <version >11.0.3 </version >
3434 <packaging >jar</packaging >
3535 <name >conottle</name >
3636 <description >A Java concurrent API to throttle the maximum concurrency to process tasks for any given client while
Original file line number Diff line number Diff line change 3333import java .util .concurrent .ExecutorService ;
3434import java .util .concurrent .Executors ;
3535
36- import static coco4j .CocoUtils .supplyByUnchecked ;
36+ import static coco4j .CocoUtils .callUnchecked ;
3737
3838/**
3939 * Not thread safe: Any and all non-private methods always should be externally synchronized while multithreading.
@@ -74,8 +74,10 @@ public boolean noPendingWorkAfterTaskComplete() {
7474 @ Override
7575 @ NonNull
7676 public <V > CompletableFuture <V > submit (Callable <V > task ) {
77- pendingTaskCount ++;
78- return CompletableFuture .supplyAsync (supplyByUnchecked (task ), taskThreadPool );
77+ return CompletableFuture .supplyAsync (() -> {
78+ pendingTaskCount ++;
79+ return callUnchecked (task );
80+ }, taskThreadPool );
7981 }
8082
8183 @ Override
Original file line number Diff line number Diff line change 3131import org .apache .commons .pool2 .impl .DefaultPooledObject ;
3232
3333/**
34- * Creates pooled {@link PendingTaskCountingThrottleExecutor} instances that provide throttled async client task executions.
35- * Each {@code PendingTaskCountingThrottleExecutor} instance throttles its client task concurrency at the max capacity of the
36- * executor's backing thread pool.
34+ * Creates pooled {@link PendingWorkAwareExecutor} instances that provide throttled async client task executions. Each
35+ * {@code PendingWorkAwareExecutor} instance throttles its client task concurrency
3736 */
3837final class PooledExecutorFactory extends BasePooledObjectFactory <PendingWorkAwareExecutor > {
3938
4039 private final int maxExecutorConcurrency ;
4140
4241 /**
4342 * @param maxExecutorConcurrency
44- * max concurrent threads of the {@link PendingTaskCountingThrottleExecutor} instance produced by this factory
43+ * max concurrent tasks that can be in execution of the {@link PendingWorkAwareExecutor} instance produced
44+ * by this factory
4545 */
4646 PooledExecutorFactory (int maxExecutorConcurrency ) {
4747 this .maxExecutorConcurrency = maxExecutorConcurrency ;
@@ -60,8 +60,8 @@ public PooledObject<PendingWorkAwareExecutor> wrap(PendingWorkAwareExecutor thro
6060 }
6161
6262 @ Override
63- public void destroyObject (PooledObject <PendingWorkAwareExecutor > pooledThrottlingExecutor ,
64- DestroyMode destroyMode ) throws Exception {
63+ public void destroyObject (PooledObject <PendingWorkAwareExecutor > pooledThrottlingExecutor , DestroyMode destroyMode )
64+ throws Exception {
6565 try {
6666 super .destroyObject (pooledThrottlingExecutor , destroyMode );
6767 } finally {
You can’t perform that action at this time.
0 commit comments