File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
src/main/java/io/api/etherscan/manager/impl Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 22
33import io .api .etherscan .manager .IQueueManager ;
44
5- import java .util .concurrent .*;
5+ import java .util .concurrent .Executors ;
6+ import java .util .concurrent .ScheduledExecutorService ;
7+ import java .util .concurrent .Semaphore ;
8+ import java .util .concurrent .TimeUnit ;
69
710/**
811 * Queue Semaphore implementation with size and reset time as params
@@ -54,7 +57,13 @@ public void takeTurn() {
5457 }
5558
5659 private Runnable releaseLocks (int toRelease ) {
57- return () -> semaphore .release (toRelease );
60+ return () -> {
61+ int availablePermits = semaphore .availablePermits ();
62+ int neededPermits = toRelease - availablePermits ;
63+ if (neededPermits > 0 ) {
64+ semaphore .release (neededPermits );
65+ }
66+ };
5867 }
5968
6069 @ Override
You can’t perform that action at this time.
0 commit comments