| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public <T extends @Nullable Object> T | callUninterruptiblyWithTimeout(Callable<T>
the Callable to execute callable, long with timeoutUnit, the maximum length of time to wait timeoutDuration, TimeUnit with timeoutDuration, the maximum length of time to wait timeoutUnit)Implements com. |
| public <T extends @Nullable Object> T | callWithTimeout(Callable<T>
the Callable to execute callable, long with timeoutUnit, the maximum length of time to wait timeoutDuration, TimeUnit with timeoutDuration, the maximum length of time to wait timeoutUnit)Implements com. |
| public <T> T | newProxy(T
the object to proxy target, Class<T> the interface you wish the returned proxy to implement interfaceType, long with timeoutUnit, the maximum length of time that callers are willing to
wait on each method call to the proxy timeoutDuration, TimeUnit with timeoutDuration, the maximum length of time that callers are willing to
wait on each method call to the proxy timeoutUnit)Implements com. interfaceType that delegates all method calls to the target object, enforcing the specified time limit on each call.
|
| public void | runUninterruptiblyWithTimeout(Runnable
the Runnable to execute runnable, long with timeoutUnit, the maximum length of time to wait timeoutDuration, TimeUnit with timeoutDuration, the maximum length of time to wait timeoutUnit)Implements com. |
| public void | runWithTimeout(Runnable
the Runnable to execute runnable, long with timeoutUnit, the maximum length of time to wait timeoutDuration, TimeUnit with timeoutDuration, the maximum length of time to wait timeoutUnit)Implements com. |
| FakeTimeLimiter | back to summary |
|---|---|
| public FakeTimeLimiter() | |
| callUninterruptiblyWithTimeout | back to summary |
|---|---|
| public <T extends @Nullable Object> T callUninterruptiblyWithTimeout(Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit) throws ExecutionException Implements com. Doc from com. Invokes a specified Callable, timing out after the specified time limit. If the target method
call finishes before the limit is reached, the return value or a wrapped exception is
propagated. If, on the other hand, the time limit is reached, we attempt to abort the call to
the target, and throw a The difference with
| |
| callWithTimeout | back to summary |
|---|---|
| public <T extends @Nullable Object> T callWithTimeout(Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit) throws ExecutionException Implements com. Doc from com. Invokes a specified Callable, timing out after the specified time limit. If the target method
call finishes before the limit is reached, the return value or a wrapped exception is
propagated. If, on the other hand, the time limit is reached, we attempt to abort the call to
the target, and throw a
| |
| newProxy | back to summary |
|---|---|
| public <T> T newProxy(T target, Class<T> interfaceType, long timeoutDuration, TimeUnit timeoutUnit) Implements com. Doc from com. Returns an instance of If the target method call finishes before the limit is reached, the return value or
exception is propagated to the caller exactly as-is. If, on the other hand, the time limit is
reached, the proxy will attempt to abort the call to the target, and will throw an It is important to note that the primary purpose of the proxy object is to return control to the caller when the timeout elapses; aborting the target method call is of secondary concern. The particular nature and strength of the guarantees made by the proxy is implementation-dependent. However, it is important that each of the methods on the target object behaves appropriately when its thread is interrupted. For example, to return the value of
TimeLimiter limiter = . . .;
TargetType proxy = limiter.newProxy(
target, TargetType.class, 50, TimeUnit.MILLISECONDS);
try {
return proxy.someMethod();
} catch (UncheckedTimeoutException e) {
return DEFAULT_VALUE;
}
| |
| runUninterruptiblyWithTimeout | back to summary |
|---|---|
| public void runUninterruptiblyWithTimeout(Runnable runnable, long timeoutDuration, TimeUnit timeoutUnit) Implements com. Doc from com. Invokes a specified Runnable, timing out after the specified time limit. If the target method
run finishes before the limit is reached, this method returns or a wrapped exception is
propagated. If, on the other hand, the time limit is reached, we attempt to abort the run, and
throw a The difference with | |
| runWithTimeout | back to summary |
|---|---|
| public void runWithTimeout(Runnable runnable, long timeoutDuration, TimeUnit timeoutUnit) Implements com. Doc from com. Invokes a specified Runnable, timing out after the specified time limit. If the target method
run finishes before the limit is reached, this method returns or a wrapped exception is
propagated. If, on the other hand, the time limit is reached, we attempt to abort the run, and
throw a | |