public void run()

in provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/AsyncFutureInvocationStrategy.java [169:213]


        public void run() {
            while(true) {
                // all currently available entries will be processed
                int takenPermits = Math.max(1, counter.availablePermits());
                try {
                    counter.acquire(takenPermits);
                }
                catch (InterruptedException e) {
                    continue;
                }
                Set<Entry<Future<Object>, CompletableFuture<Object >>> entrySet = futures.entrySet();
                int processed = 0;
                for (Entry<Future<Object>, CompletableFuture<Object>> entry : entrySet) {
                    if(processed == takenPermits) {
                        //we only release as many as we took permits. The remainder will be handled in the next iteration
                        break;
                    }
                    Future< ? > future = entry.getKey();
                    if(future.isDone()) {
                        try {
                            Object object = future.get();
                            entry.getValue().complete(object);
                        }
                        catch (ExecutionException e) {
                            entry.getValue().completeExceptionally(e.getCause());
                        }
                        catch (Exception e) {
                            entry.getValue().completeExceptionally(e);
                        }
                        futures.remove(future);
                        processed++;
                    }
                    else {
                        // if the future is complete, the permit is not released
                        counter.release();
                    }
                    try {
                        Thread.sleep(20);
                    }
                    catch (InterruptedException e) {
                        // sleep a little to wait for additional futures to complete
                    }
                }
            }
        }