Skip to content

Commit ec17d45

Browse files
committed
+ internal PendingTaskCountingThrottleExecutor method change
1 parent 4776c06 commit ec17d45

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
<groupId>io.github.q3769</groupId>
3232
<artifactId>conottle</artifactId>
33-
<version>11.0.4</version>
33+
<version>11.0.5</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

src/main/java/conottle/Conottle.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ public <V> CompletableFuture<V> submit(@NonNull Callable<V> task, @NonNull Objec
8686
CompletableFuture<V> copy = taskCompletableFuture.thenApply(r -> r);
8787
taskCompletableFuture.whenCompleteAsync((r, e) -> activeThrottlingExecutors.computeIfPresent(clientId,
8888
(k, checkedExecutor) -> {
89-
if (checkedExecutor.noPendingWorkAfterTaskComplete()) {
90-
returnToPool(checkedExecutor);
91-
return null;
89+
if (checkedExecutor.moreWorkPendingAfterTaskComplete()) {
90+
return checkedExecutor;
9291
}
93-
return checkedExecutor;
92+
returnToPool(checkedExecutor);
93+
return null;
9494
}), adminExecutorService);
9595
return copy;
9696
}

src/main/java/conottle/PendingTaskCountingThrottleExecutor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ final class PendingTaskCountingThrottleExecutor implements PendingWorkAwareExecu
6464
* completed task
6565
*/
6666
@Override
67-
public boolean noPendingWorkAfterTaskComplete() {
67+
public boolean moreWorkPendingAfterTaskComplete() {
6868
if (pendingTaskCount <= 0) {
6969
throw new IllegalStateException("Cannot further decrement from pending task count: " + pendingTaskCount);
7070
}
71-
return --pendingTaskCount == 0;
71+
return --pendingTaskCount != 0;
7272
}
7373

7474
@Override

src/main/java/conottle/PendingWorkAwareExecutor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ interface PendingWorkAwareExecutor {
3636
/**
3737
* Intended to be called after each task is completed by this service.
3838
*
39-
* @return true if this executor has no more pending tasks after the task whose completion triggered this method
39+
* @return true if this executor has more pending tasks after the task whose completion triggered this method
4040
* invocation
4141
*/
42-
boolean noPendingWorkAfterTaskComplete();
42+
boolean moreWorkPendingAfterTaskComplete();
4343

4444
@NonNull <V> CompletableFuture<V> submit(Callable<V> task);
4545

0 commit comments

Comments
 (0)