Package com.peterphi.std.threading
Class SettableFuture<T>
java.lang.Object
com.peterphi.std.threading.SettableFuture<T>
- Type Parameters:
T
-
- All Implemented Interfaces:
Future<T>
- Direct Known Subclasses:
RunnableCallableFuture
A simple Future whose value will be set at some later date
-
Constructor Summary
ConstructorDescriptionSettableFuture
(ParamInvokeable<SettableFuture<T>> onSet, ParamInvokeable<SettableFuture<T>> onCancel) Create a SettableFuture which will potentially execute tasks upon set and upon cancel; the handlers will hold the exclusive lock on the monitor for the duration of their execution
The handlers, (as they are ParamInvokeables) run synchronously with the call toset
orcancel
; they run after the effects have taken place and after any interested parties waiting on the monitor have been notified -
Method Summary
-
Constructor Details
-
SettableFuture
public SettableFuture() -
SettableFuture
public SettableFuture(ParamInvokeable<SettableFuture<T>> onSet, ParamInvokeable<SettableFuture<T>> onCancel) Create a SettableFuture which will potentially execute tasks upon set and upon cancel; the handlers will hold the exclusive lock on the monitor for the duration of their execution
The handlers, (as they are ParamInvokeables) run synchronously with the call toset
orcancel
; they run after the effects have taken place and after any interested parties waiting on the monitor have been notified- Parameters:
onSet
-onCancel
-
-
-
Method Details
-
set
-
fail
-
on_set
protected void on_set() -
cancel
public boolean cancel(boolean mayInterruptIfRunning) -
cancel
public boolean cancel()Cancels this Future- Returns:
-
on_cancel
protected void on_cancel() -
get
- Specified by:
get
in interfaceFuture<T>
- Throws:
InterruptedException
ExecutionException
-
poll
- Throws:
ExecutionException
-
get
public final T get(long quantity, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
get
in interfaceFuture<T>
- Throws:
InterruptedException
ExecutionException
TimeoutException
-
get
public final T get(Deadline deadline) throws InterruptedException, ExecutionException, TimeoutException -
isCancelled
public boolean isCancelled()- Specified by:
isCancelled
in interfaceFuture<T>
-
isDone
public boolean isDone()
-