private void poll(long timeout, long now, boolean executeDelayedTasks) { // send all the requests we can send now trySend(now); // ensure we don't poll any longer than the deadline for // the next scheduled task timeout = Math.min(timeout, delayedTasks.nextTimeout(now)); clientPoll(timeout, now); now = time.milliseconds(); // handle any disconnects by failing the active requests. note that disconnects must // be checked immediately following poll since any subsequent call to client.ready() // will reset the disconnect status checkDisconnects(now); // execute scheduled tasks if (executeDelayedTasks) delayedTasks.poll(now); // try again to send requests since buffer space may have been // cleared or a connect finished in the poll trySend(now); // fail requests that couldn't be sent if they have expired failExpiredRequests(now); }
/** * Execute delayed tasks now. * * @param now current time in milliseconds * @throws WakeupException if a wakeup has been requested */ public void executeDelayedTasks(long now) { delayedTasks.poll(now); maybeTriggerWakeup(); }