Class TimerUtils
- java.lang.Object
-
- software.amazon.awssdk.core.internal.http.timers.TimerUtils
-
public final class TimerUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static longresolveTimeoutInMillis(Supplier<Optional<Duration>> supplier, Duration fallback)static <T> TimeoutTrackertimeAsyncTaskIfNeeded(CompletableFuture<T> completableFuture, ScheduledExecutorService timeoutExecutor, Supplier<SdkClientException> exceptionSupplier, long timeoutInMills)Schedule aTimeoutTaskand exceptional completes aCompletableFuturewith the provide exception if not otherwise completed before the given timeout.static TimeoutTrackertimeSyncTaskIfNeeded(ScheduledExecutorService timeoutExecutor, long timeoutInMills, Thread threadToInterrupt)Schedule aTimeoutTaskthat aborts the task if not otherwise completed before the given timeout.
-
-
-
Method Detail
-
timeAsyncTaskIfNeeded
public static <T> TimeoutTracker timeAsyncTaskIfNeeded(CompletableFuture<T> completableFuture, ScheduledExecutorService timeoutExecutor, Supplier<SdkClientException> exceptionSupplier, long timeoutInMills)
Schedule aTimeoutTaskand exceptional completes aCompletableFuturewith the provide exception if not otherwise completed before the given timeout.- Type Parameters:
T- the type of theCompletableFuture- Parameters:
completableFuture- the completableFuture to be timedtimeoutExecutor- the executor to execute theTimeoutTaskexceptionSupplier- the exception to thrown after timeouttimeoutInMills- the timeout in milliseconds.- Returns:
- a
TimeoutTracker
-
timeSyncTaskIfNeeded
public static TimeoutTracker timeSyncTaskIfNeeded(ScheduledExecutorService timeoutExecutor, long timeoutInMills, Thread threadToInterrupt)
Schedule aTimeoutTaskthat aborts the task if not otherwise completed before the given timeout.- Parameters:
timeoutExecutor- the executor to execute theTimeoutTasktimeoutInMills- the timeout in milliseconds.threadToInterrupt- the thread to interrupt- Returns:
- a
TimeoutTracker
-
-