Example usage for com.google.common.util.concurrent UncheckedTimeoutException UncheckedTimeoutException

List of usage examples for com.google.common.util.concurrent UncheckedTimeoutException UncheckedTimeoutException

Introduction

In this page you can find the example usage for com.google.common.util.concurrent UncheckedTimeoutException UncheckedTimeoutException.

Prototype

public UncheckedTimeoutException() 

Source Link

Usage

From source file:io.prestosql.tests.AbstractTestDistributedQueries.java

private <T> T waitUntilStable(Supplier<T> computation, Duration timeout) {
    T lastValue = computation.get();// www  .  jav  a 2s  .  c om
    long start = System.nanoTime();
    while (!currentThread().isInterrupted() && nanosSince(start).compareTo(timeout) < 0) {
        sleepUninterruptibly(100, MILLISECONDS);
        T currentValue = computation.get();
        if (currentValue.equals(lastValue)) {
            return currentValue;
        }
        lastValue = currentValue;
    }
    throw new UncheckedTimeoutException();
}