Package jadex.future
Class TerminableFuture<E>
java.lang.Object
jadex.future.Future<E>
jadex.future.TerminableFuture<E>
- All Implemented Interfaces:
IBackwardCommandFuture,IForwardCommandFuture,IFuture<E>,ITerminableFuture<E>,Supplier<E>
Future that can be terminated from caller side.
A termination request leads to setException() being
called with a FutureTerminatedException.
The future can be supplied with a command that
gets executed if terminate is called.
-
Nested Class Summary
Nested classes/interfaces inherited from interface jadex.future.IForwardCommandFuture
IForwardCommandFuture.Type -
Field Summary
FieldsModifier and TypeFieldDescriptionThe list of backward commands.protected ITerminationCommandThe termination code.Fields inherited from class jadex.future.Future
CALLER_QUEUED, CALLER_RESUMED, CALLER_SUSPENDED, callers, creation, DEBUG, exception, first, listeners, NO_STACK_COMPACTION, NONE, notcommand, NOTIFICATIONS, notificount, notified, result, resultavailable, undone, UNSET -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new future.TerminableFuture(ITerminationCommand terminate) Create a future that is already done. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBackwardCommand(jadex.common.IFilter<Object> filter, jadex.common.ICommand<Object> command) Add a backward command with a filter.voidremoveBackwardCommand(jadex.common.ICommand<Object> command) Add a command with a filter.voidsendBackwardCommand(Object info) Send a backward command in direction of the source.voidsetTerminationCommand(ITerminationCommand terminate) Set the termination command.voidTerminate the future.voidTerminate the future and supply a custom reason.Methods inherited from class jadex.future.Future
abortGet, addResultListener, catchEx, catchEx, catchEx, delegate, delegateFrom, delegateTo, doAddResultListener, doSetException, doSetResult, doStartScheduledNotifications, executeNotification, get, get, get, get, get, getEmptyFuture, getException, getFuture, getNotificationCommand, hasResultListener, isDone, isNotified, printOnEx, resume, scheduleNotification, scheduleNotification, sendForwardCommand, setException, setExceptionIfUndone, setResult, setResultIfUndone, startScheduledNotifications, then, thenAccept, thenAccept, thenApply, thenApply, thenCombine, thenCompose, thenCompose, throwExceptionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jadex.future.IFuture
addResultListener, catchEx, catchEx, catchEx, delegate, delegateTo, get, get, get, get, get, getException, isDone, printOnEx, then, thenApply, thenApply, thenCompose, thenCompose
-
Field Details
-
terminate
The termination code. -
bcommands
The list of backward commands.
-
-
Constructor Details
-
TerminableFuture
public TerminableFuture()Create a new future. -
TerminableFuture
Create a future that is already done.- Parameters:
terminate- The termination command.
-
-
Method Details
-
terminate
public void terminate()Terminate the future. The exception will be set to FutureTerminatedException.- Specified by:
terminatein interfaceITerminableFuture<E>
-
terminate
Terminate the future and supply a custom reason.- Specified by:
terminatein interfaceITerminableFuture<E>
-
sendBackwardCommand
Send a backward command in direction of the source.- Specified by:
sendBackwardCommandin interfaceIBackwardCommandFuture- Parameters:
info- The command info.
-
addBackwardCommand
public void addBackwardCommand(jadex.common.IFilter<Object> filter, jadex.common.ICommand<Object> command) Add a backward command with a filter. Whenever the future receives an info it will check all registered filters. -
removeBackwardCommand
Add a command with a filter. Whenever the future receives an info it will check all registered filters. -
setTerminationCommand
Set the termination command.- Parameters:
terminate- The termination command.
-