예제 #1
0
 /** Retries sending requests. */
 private void retryRequests() {
   retryFuture = null;
   List<Runnable> retries = new ArrayList<>(this.retries);
   this.retries.clear();
   resetMembers();
   for (Runnable retry : retries) {
     retry.run();
   }
 }
예제 #2
0
  /** Sequences a query response. */
  private void sequenceResponse(long sequence, Runnable callback) {
    // If the response is for the next sequence number (the response is received in order),
    // complete the future as appropriate. Note that some prior responses may have been received
    // out of order, so once this response is completed, complete any following responses that
    // are in sequence.
    if (sequence == responseSequence + 1) {
      responseSequence++;

      callback.run();

      // Iterate through responses in sequence if available and trigger completion callbacks that
      // are in sequence.
      while (responses.containsKey(responseSequence + 1)) {
        responses.remove(++responseSequence).run();
      }
    } else {
      responses.put(sequence, callback);
    }
  }
예제 #3
0
 @Override
 @SuppressWarnings("unchecked")
 public Listener<Void> onEvent(String event, Runnable callback) {
   return onEvent(event, v -> callback.run());
 }