larksuite-oapi/src/main/java/com/larksuite/oapi/okhttp3_14/Dispatcher.java
private boolean promoteAndExecute() {
    assert (!Thread.holdsLock(this));

    List<AsyncCall> executableCalls = new ArrayList<>();
    boolean isRunning;
    synchronized (this) {
      for (Iterator<AsyncCall> i = readyAsyncCalls.iterator(); i.hasNext(); ) {
        AsyncCall asyncCall = i.next();

        if (runningAsyncCalls.size() >= maxRequests) break; // Max capacity.
        if (asyncCall.callsPerHost().get() >= maxRequestsPerHost) continue; // Host max capacity.

        i.remove();
        asyncCall.callsPerHost().incrementAndGet();
        executableCalls.add(asyncCall);
        runningAsyncCalls.add(asyncCall);
      }
      isRunning = runningCallsCount() > 0;
    }

    for (int i = 0, size = executableCalls.size(); i < size; i++) {
      AsyncCall asyncCall = executableCalls.get(i);
      asyncCall.executeOn(executorService());
    }

    return isRunning;
  }
/**
   * Promotes eligible calls from {@link #readyAsyncCalls} to {@link #runningAsyncCalls} and runs
   * them on the executor service. Must not be called with synchronization because executing calls
   * can call into user code.
   *
   * @return true if the dispatcher is currently running calls.
   */
Promotes eligible calls from  #readyAsyncCalls to  #runningAsyncCalls and runs
them on the executor service. Must not be called with synchronization because executing calls
can call into user code.

@return true if the dispatcher is currently running calls.
Promotes eligible calls from #readyAsyncCalls to #runningAsyncCalls and runs them on the executor service . Must not be called with synchronization because executing calls can call into user code . @return true if the dispatcher is currently running calls .
private boolean promoteAndExecute() {
    assert (!Thread.holdsLock(this));
    List<AsyncCall> executableCalls = new ArrayList<>();
    boolean isRunning;
    synchronized (this) {
      for (Iterator<AsyncCall> i = readyAsyncCalls.iterator(); i.hasNext(); ) {
        AsyncCall asyncCall = i.next();
        if (runningAsyncCalls.size() >= maxRequests) break; 
        if (asyncCall.callsPerHost().get() >= maxRequestsPerHost) continue; 
        i.remove();
        asyncCall.callsPerHost().incrementAndGet();
        executableCalls.add(asyncCall);
        runningAsyncCalls.add(asyncCall);
      }
      isRunning = runningCallsCount() > 0;
    }
    for (int i = 0, size = executableCalls.size(); i < size; i++) {
      AsyncCall asyncCall = executableCalls.get(i);
      asyncCall.executeOn(executorService());
    }
    return isRunning;
  }
private boolean promoteAndExecute ( ) { assert ( ! Thread . holdsLock ( this ) ) ; List < AsyncCall > executableCalls = new ArrayList < > ( ) ; boolean isRunning ; synchronized ( this ) { for ( Iterator < AsyncCall > i = readyAsyncCalls . iterator ( ) ; i . hasNext ( ) ; ) { AsyncCall asyncCall = i . next ( ) ; if ( runningAsyncCalls . size ( ) >= maxRequests ) break ; if ( asyncCall . callsPerHost ( ) . get ( ) >= maxRequestsPerHost ) continue ; i . remove ( ) ; asyncCall . callsPerHost ( ) . incrementAndGet ( ) ; executableCalls . add ( asyncCall ) ; runningAsyncCalls . add ( asyncCall ) ; } isRunning = runningCallsCount ( ) > 0 ; } for ( int i = 0 , size = executableCalls . size ( ) ; i < size ; i ++ ) { AsyncCall asyncCall = executableCalls . get ( i ) ; asyncCall . executeOn ( executorService ( ) ) ; } return isRunning ; }
Promotes eligible calls from {@link #readyAsyncCalls} to {@link #runningAsyncCalls} and runs
 them on the executor service.
Promotes eligible calls from { @link #readyAsyncCalls } to { @link #runningAsyncCalls } and runs them on the executor service .
// Max capacity. // Host max capacity.