Package dev.gmitch215.bytebox.locks
Interface Future<V>
- Type Parameters:
V- the value type
- All Known Implementing Classes:
CompletableFuture
public interface Future<V>
java.util.concurrent.Future, which the class library does not carry. Only the five methods
a CompletableFuture implements are here; the default methods Java 19 added are not.- Since:
- 1.0.3
-
Method Details
-
cancel
boolean cancel(boolean mayInterruptIfRunning) - Parameters:
mayInterruptIfRunning- ignored byCompletableFuture- Returns:
- whether the future is now cancelled
-
isCancelled
boolean isCancelled()Returns whether the future was cancelled.- Returns:
- whether the future was cancelled
-
isDone
boolean isDone()Returns whether the future has a result, a failure or was cancelled.- Returns:
- whether the future has a result, a failure or was cancelled
-
get
Suspends the caller until the future is done.- Returns:
- the value
- Throws:
InterruptedException- if the caller was interrupted while waitingExecutionException- if the future failed
-
get
V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Parameters:
timeout- the longest to waitunit- the unit oftimeout- Returns:
- the value
- Throws:
InterruptedException- if the caller was interrupted while waitingExecutionException- if the future failedTimeoutException- if the time ran out first
-