Package jadex.future
Class TerminableIntermediateFuture<E>
java.lang.Object
jadex.future.Future<Collection<E>>
jadex.future.IntermediateFuture<E>
jadex.future.TerminableIntermediateFuture<E>
- All Implemented Interfaces:
IBackwardCommandFuture
,IForwardCommandFuture
,IFuture<Collection<E>>
,IIntermediateFuture<E>
,ITerminableFuture<Collection<E>>
,ITerminableIntermediateFuture<E>
,Supplier<Collection<E>>
- Direct Known Subclasses:
PullIntermediateFuture
,SubscriptionIntermediateFuture
public class TerminableIntermediateFuture<E>
extends IntermediateFuture<E>
implements ITerminableIntermediateFuture<E>
Intermediate 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 ITerminationCommand
The termination code.Fields inherited from class jadex.future.IntermediateFuture
icallers, indices, intermediate, maxresultcnt, notcommand, results
Fields inherited from class jadex.future.Future
CALLER_QUEUED, CALLER_RESUMED, CALLER_SUSPENDED, callers, creation, DEBUG, exception, first, listeners, NO_STACK_COMPACTION, NONE, NOTIFICATIONS, notificount, notified, result, resultavailable, undone, UNSET
Fields inherited from interface jadex.future.IIntermediateFuture
DONE
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new future.TerminableIntermediateFuture
(ITerminationCommand terminate) Create a new future.TerminableIntermediateFuture
(Exception exception) Create a future that is already done (failed). -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBackwardCommand
(jadex.common.IFilter<Object> filter, jadex.common.ICommand<Object> command) Add a backward command with a filter.Get the terminate.void
removeBackwardCommand
(jadex.common.ICommand<Object> command) Add a command with a filter.void
sendBackwardCommand
(Object info) Send a backward command in direction of the source.void
setTerminationCommand
(ITerminationCommand terminate) Set the terminate.void
Terminate the future.void
Terminate the future and supply a custom reason.Methods inherited from class jadex.future.IntermediateFuture
addIntermediateResult, addIntermediateResultIfUndone, addResultListener, asStream, asStream, catchEx, delegateEx, delegateFrom, doAddIntermediateResult, doGetNextIntermediateResult, done, doSetException, doSetFinished, doSetResult, finished, getIntermediateResults, getNextIntermediateResult, getNextIntermediateResult, getNextIntermediateResult, getNotificationCommand, getResultCount, hasNextIntermediateResult, hasNextIntermediateResult, max, next, notifyIntermediateResult, resume, resumeIntermediate, scheduleMaxNotification, setFinished, setFinishedIfUndone, setMaxResultCount, storeResult, then
Methods inherited from class jadex.future.Future
abortGet, catchEx, catchEx, delegate, delegateTo, doAddResultListener, doStartScheduledNotifications, executeNotification, get, get, get, get, get, getEmptyFuture, getException, getFuture, hasResultListener, isDone, isNotified, printOnEx, scheduleNotification, scheduleNotification, sendForwardCommand, setException, setExceptionIfUndone, setResult, setResultIfUndone, startScheduledNotifications, thenAccept, thenAccept, thenApply, thenApply, thenCombine, thenCompose, thenCompose, throwException
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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
Methods inherited from interface jadex.future.IIntermediateFuture
asStream, asStream, done, finished, getIntermediateResults, getNextIntermediateResult, getNextIntermediateResult, hasNextIntermediateResult, hasNextIntermediateResult, max, next
-
Field Details
-
terminate
The termination code. -
bcommands
The list of backward commands.
-
-
Constructor Details
-
TerminableIntermediateFuture
public TerminableIntermediateFuture()Create a new future. -
TerminableIntermediateFuture
Create a future that is already done (failed).- Parameters:
exception
- The exception.
-
TerminableIntermediateFuture
Create a new future.- Parameters:
terminate
- The runnable to be executed in case of termination.
-
-
Method Details
-
terminate
public void terminate()Terminate the future. The exception will be set to FutureTerminatedException.- Specified by:
terminate
in interfaceITerminableFuture<E>
-
terminate
Terminate the future and supply a custom reason.- Specified by:
terminate
in interfaceITerminableFuture<E>
-
getTerminationCommand
Get the terminate.- Returns:
- The terminate.
-
setTerminationCommand
Set the terminate.- Parameters:
terminate
- The terminate to set.
-
sendBackwardCommand
Send a backward command in direction of the source.- Specified by:
sendBackwardCommand
in 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.
-