Class DeadlineGuard
java.lang.Object
io.helidon.common.task.DeadlineGuard
- All Implemented Interfaces:
AutoCloseable
Guard for a scoped operation with a deadline.
The guard schedules an action to run when the configured timeout expires. Closing the guard cancels the scheduled action if it has not already run.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static DeadlineGuardCreates a new guard and starts its timeout immediately.booleantimedOut()Whether this guard's timeout elapsed and its timeout action was invoked.Failure thrown by the timeout action, if any.
-
Method Details
-
create
Creates a new guard and starts its timeout immediately.A zero or negative timeout creates a guard that never expires.
- Parameters:
timeout- timeout to wait before invoking the timeout actiontimeoutAction- action to invoke when the timeout expires- Returns:
- active deadline guard
-
timedOut
public boolean timedOut()Whether this guard's timeout elapsed and its timeout action was invoked.- Returns:
- whether the guard timed out
-
timeoutActionFailure
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-