public boolean poll(long timeout, TimeUnit unit, Supplier<Boolean> function) {
    long startWaitTime = System.currentTimeMillis();
    long waitTime = unit.toMillis(timeout);

    do {
      try {
        if (function.get()) {
          return true;
        }

        Thread.sleep(100);
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        return false;
      }
    } while (System.currentTimeMillis() - startWaitTime < waitTime);

    return false;

  }
Very basic polling functionality that executes a function until it returns true or the timeout
is reached. The polling call is performed on the calling thread. Do not use it with a
function that may have an unbounded runtime. The timeout is very coarse and will not account
for the function overrunning the given time.

@param timeout the maximum amount of time to wait for the function to return
@param unit the {@link TimeUnit} for the timeout
@param function a {@link Supplier Supplier&lt;Boolean&gt;} function that will poll for the
       condition
@return true if the function returns true within the timeout period; false otherwise
geode-gfsh/src/main/java/org/apache/geode/management/cli/GfshCommand.java