larksuite-oapi/src/main/java/com/larksuite/oapi/okio1_17/AsyncTimeout.java
static @Nullable
  AsyncTimeout awaitTimeout() throws InterruptedException {
    // Get the next eligible node.
    AsyncTimeout node = head.next;

    // The queue is empty. Wait until either something is enqueued or the idle timeout elapses.
    if (node == null) {
      long startNanos = System.nanoTime();
      AsyncTimeout.class.wait(IDLE_TIMEOUT_MILLIS);
      return head.next == null && (System.nanoTime() - startNanos) >= IDLE_TIMEOUT_NANOS
          ? head  // The idle timeout elapsed.
          : null; // The situation has changed.
    }

    long waitNanos = node.remainingNanos(System.nanoTime());

    // The head of the queue hasn't timed out yet. Await that.
    if (waitNanos > 0) {
      // Waiting is made complicated by the fact that we work in nanoseconds,
      // but the API wants (millis, nanos) in two arguments.
      long waitMillis = waitNanos / 1000000L;
      waitNanos -= (waitMillis * 1000000L);
      AsyncTimeout.class.wait(waitMillis, (int) waitNanos);
      return null;
    }

    // The head of the queue has timed out. Remove it.
    head.next = node.next;
    node.next = null;
    return node;
  }
/**
   * Removes and returns the node at the head of the list, waiting for it to time out if necessary.
   * This returns {@link #head} if there was no node at the head of the list when starting, and
   * there continues to be no node after waiting {@code IDLE_TIMEOUT_NANOS}. It returns null if a
   * new node was inserted while waiting. Otherwise this returns the node being waited on that has
   * been removed.
   */
Removes and returns the node at the head of the list, waiting for it to time out if necessary.
This returns  #head if there was no node at the head of the list when starting, and
there continues to be no node after waiting  IDLE_TIMEOUT_NANOS. It returns null if a
new node was inserted while waiting. Otherwise this returns the node being waited on that has
been removed.
Removes and returns the node at the head of the list waiting for it to time out if necessary . This returns #head if there was no node at the head of the list when starting and there continues to be no node after waiting IDLE_TIMEOUT_NANOS . It returns null if a new node was inserted while waiting . Otherwise this returns the node being waited on that has been removed .
static @Nullable
  AsyncTimeout awaitTimeout() throws InterruptedException {
    AsyncTimeout node = head.next;
    if (node == null) {
      long startNanos = System.nanoTime();
      AsyncTimeout.class.wait(IDLE_TIMEOUT_MILLIS);
      return head.next == null && (System.nanoTime() - startNanos) >= IDLE_TIMEOUT_NANOS
          ? head  
          : null; 
    }
    long waitNanos = node.remainingNanos(System.nanoTime());
    if (waitNanos > 0) {
      long waitMillis = waitNanos / 1000000L;
      waitNanos -= (waitMillis * 1000000L);
      AsyncTimeout.class.wait(waitMillis, (int) waitNanos);
      return null;
    }
    head.next = node.next;
    node.next = null;
    return node;
  }
static @ Nullable AsyncTimeout awaitTimeout ( ) throws InterruptedException { AsyncTimeout node = head . next ; if ( node == null ) { long startNanos = System . nanoTime ( ) ; AsyncTimeout . class . wait ( IDLE_TIMEOUT_MILLIS ) ; return head . next == null && ( System . nanoTime ( ) - startNanos ) >= IDLE_TIMEOUT_NANOS ? head : null ; } long waitNanos = node . remainingNanos ( System . nanoTime ( ) ) ; if ( waitNanos > 0 ) { long waitMillis = waitNanos / 1000000L ; waitNanos -= ( waitMillis * 1000000L ) ; AsyncTimeout . class . wait ( waitMillis , ( int ) waitNanos ) ; return null ; } head . next = node . next ; node . next = null ; return node ; }
Removes and returns the node at the head of the list, waiting for it to time out if necessary.
Removes and returns the node at the head of the list waiting for it to time out if necessary .
// Get the next eligible node. // The queue is empty. Wait until either something is enqueued or the idle timeout elapses. // The idle timeout elapsed. // The situation has changed. // The head of the queue hasn't timed out yet. Await that. // Waiting is made complicated by the fact that we work in nanoseconds, // but the API wants (millis, nanos) in two arguments. // The head of the queue has timed out. Remove it.