/**
  * Block until the provided request future request has finished or the timeout has expired.
  *
  * @param future The request future to wait for
  * @param timeout The maximum duration (in ms) to wait for the request
  * @return true if the future is done, false otherwise
  * @throws WakeupException if {@link #wakeup()} is called from another thread
  */
 public boolean poll(RequestFuture<?> future, long timeout) {
   long begin = time.milliseconds();
   long remaining = timeout;
   long now = begin;
   do {
     poll(remaining, now, true);
     now = time.milliseconds();
     long elapsed = now - begin;
     remaining = timeout - elapsed;
   } while (!future.isDone() && remaining > 0);
   return future.isDone();
 }
 /**
  * Block indefinitely until the given request future has finished.
  *
  * @param future The request future to await.
  * @throws WakeupException if {@link #wakeup()} is called from another thread
  */
 public void poll(RequestFuture<?> future) {
   while (!future.isDone()) poll(Long.MAX_VALUE);
 }