Package jadex.commons.future
Class SubscriptionIntermediateDelegationFuture<E>
- java.lang.Object
- 
- jadex.commons.future.Future<java.util.Collection<E>>
- 
- jadex.commons.future.IntermediateFuture<E>
- 
- jadex.commons.future.TerminableIntermediateDelegationFuture<E>
- 
- jadex.commons.future.SubscriptionIntermediateDelegationFuture<E>
 
 
 
 
- 
- All Implemented Interfaces:
- IBackwardCommandFuture,- IForwardCommandFuture,- IFuture<java.util.Collection<E>>,- IIntermediateFuture<E>,- ISubscriptionIntermediateFuture<E>,- ITerminableFuture<java.util.Collection<E>>,- ITerminableIntermediateFuture<E>
 - Direct Known Subclasses:
- PullSubscriptionIntermediateDelegationFuture
 
 public class SubscriptionIntermediateDelegationFuture<E> extends TerminableIntermediateDelegationFuture<E> implements ISubscriptionIntermediateFuture<E> 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface jadex.commons.future.IForwardCommandFutureIForwardCommandFuture.Type
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected java.util.Map<java.lang.Thread,java.util.List<E>>ownresultsThe local results for a single thread.protected intresultssizeThe number of results.protected booleanstoreforfirstFlag if results should be stored till first listener is.- 
Fields inherited from class jadex.commons.future.TerminableIntermediateDelegationFuturenotified, notify, reason, src, storedinfos
 - 
Fields inherited from class jadex.commons.future.IntermediateFutureicallers, indices, intermediate, maxresultcnt, notcommand, results
 - 
Fields inherited from class jadex.commons.future.FutureCALLER_QUEUED, CALLER_RESUMED, CALLER_SUSPENDED, callers, creation, DEBUG, exception, first, listener, listeners, NO_STACK_COMPACTION, NONE, notifications, result, resultavailable, STACK, undone, UNSET
 - 
Fields inherited from interface jadex.commons.future.IIntermediateFutureDONE
 
- 
 - 
Constructor SummaryConstructors Constructor Description SubscriptionIntermediateDelegationFuture()Create a new future.SubscriptionIntermediateDelegationFuture(ITerminableIntermediateFuture<?> src)Create a new future.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddQuietListener(IResultListener<java.util.Collection<E>> listener)Add a listener which is only informed about new results, i.e.voidaddResultListener(IResultListener<java.util.Collection<E>> listener)Add a result listener.protected EdoGetNextIntermediateResult(int index, long timeout, boolean realtime)Perform the get without increasing the index.java.util.Collection<E>getIntermediateResults()Get the intermediate results that are available.EgetNextIntermediateResult(long timeout, boolean realtime)Iterate over the intermediate results in a blocking fashion.protected intgetResultCount()Get the number of results already collected.booleanhasNextIntermediateResult(long timeout, boolean realtime)Check if there are more results for iteration for the given caller.protected booleanstoreResult(E result)Add a result.- 
Methods inherited from class jadex.commons.future.TerminableIntermediateDelegationFuturedoNotify, getSource, sendBackwardCommand, setSource, terminate, terminate
 - 
Methods inherited from class jadex.commons.future.IntermediateFutureaddIntermediateResult, addIntermediateResultIfUndone, addIntermediateResultListener, catchErr, doAddIntermediateResult, doSetFinished, doSetResult, finished, flatMapAsync, getNextIntermediateResult, getNextIntermediateResult, getNotificationCommand, hasNextIntermediateResult, mapAsync, mapAsync, max, next, notifyIntermediateResult, resume, resumeIntermediate, scheduleMaxNotification, setFinished, setFinishedIfUndone, setMaxResultCount
 - 
Methods inherited from class jadex.commons.future.FutureabortGet, catchErr, catchErr, delegate, doSetException, executeNotification, get, get, get, get, get, getEmptyFuture, getException, getFuture, hasResultListener, isDone, notifyListener, notifyListener, scheduleNotification, scheduleNotification, scheduleNotification, sendForwardCommand, setException, setExceptionIfUndone, setResult, setResultIfUndone, startScheduledNotifications, then, thenAccept, thenAccept, thenApply, thenApply, thenCombine, thenCompose, thenCompose
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface jadex.commons.future.IBackwardCommandFuturesendBackwardCommand
 - 
Methods inherited from interface jadex.commons.future.IFuturecatchErr, catchErr, catchErr, delegate, get, get, get, get, get, getException, isDone, then, thenApply, thenApply, thenCompose, thenCompose
 - 
Methods inherited from interface jadex.commons.future.IIntermediateFuturefinished, flatMapAsync, getNextIntermediateResult, hasNextIntermediateResult, mapAsync, mapAsync, max, next
 - 
Methods inherited from interface jadex.commons.future.ITerminableFutureterminate, terminate
 
- 
 
- 
- 
- 
Field Detail- 
ownresultsprotected java.util.Map<java.lang.Thread,java.util.List<E>> ownresults The local results for a single thread.
 - 
storeforfirstprotected boolean storeforfirst Flag if results should be stored till first listener is.
 - 
resultssizeprotected int resultssize The number of results.
 
- 
 - 
Constructor Detail- 
SubscriptionIntermediateDelegationFuturepublic SubscriptionIntermediateDelegationFuture() Create a new future.
 - 
SubscriptionIntermediateDelegationFuturepublic SubscriptionIntermediateDelegationFuture(ITerminableIntermediateFuture<?> src) Create a new future.
 
- 
 - 
Method Detail- 
storeResultprotected boolean storeResult(E result) Add a result.- Overrides:
- storeResultin class- IntermediateFuture<E>
- Parameters:
- result- The result.
 
 - 
getResultCountprotected int getResultCount() Get the number of results already collected.- Overrides:
- getResultCountin class- IntermediateFuture<E>
- Returns:
- The number of results.
 
 - 
addQuietListenerpublic void addQuietListener(IResultListener<java.util.Collection<E>> listener) Add a listener which is only informed about new results, i.e. the initial results are not posted to this listener, even if it is the first listener to be added to this future.- Specified by:
- addQuietListenerin interface- ISubscriptionIntermediateFuture<E>
 
 - 
addResultListenerpublic void addResultListener(IResultListener<java.util.Collection<E>> listener) Add a result listener.- Specified by:
- addResultListenerin interface- IFuture<E>
- Overrides:
- addResultListenerin class- IntermediateFuture<E>
- Parameters:
- listener- The listener.
 
 - 
getIntermediateResultspublic java.util.Collection<E> getIntermediateResults() Get the intermediate results that are available. Note: The semantics of this method is different to the normal intermediate future due to the fire-and-forget-semantics!- Specified by:
- getIntermediateResultsin interface- IIntermediateFuture<E>
- Specified by:
- getIntermediateResultsin interface- ISubscriptionIntermediateFuture<E>
- Overrides:
- getIntermediateResultsin class- IntermediateFuture<E>
- Returns:
- 1)
 
 - 
getNextIntermediateResultpublic E getNextIntermediateResult(long timeout, boolean realtime) Iterate over the intermediate results in a blocking fashion. Manages results independently for different callers, i.e. when called from different threads, each thread receives all intermediate results. The operation is guaranteed to be non-blocking, if hasNextIntermediateResult() has returned true before for the same caller. Otherwise the caller is blocked until a result is available or the future is finished.- Specified by:
- getNextIntermediateResultin interface- IIntermediateFuture<E>
- Overrides:
- getNextIntermediateResultin class- IntermediateFuture<E>
- Parameters:
- timeout- The timeout in millis.
- realtime- Flag, if wait should be realtime (in constrast to simulation time).
- Returns:
- The next intermediate result.
 
 - 
hasNextIntermediateResultpublic boolean hasNextIntermediateResult(long timeout, boolean realtime)Check if there are more results for iteration for the given caller. If there are currently no unprocessed results and future is not yet finished, the caller is blocked until either new results are available and true is returned or the future is finished, thus returning false.- Specified by:
- hasNextIntermediateResultin interface- IIntermediateFuture<E>
- Overrides:
- hasNextIntermediateResultin class- IntermediateFuture<E>
- Parameters:
- timeout- The timeout in millis.
- realtime- Flag, if wait should be realtime (in constrast to simulation time).
- Returns:
- True, when there are more intermediate results for the caller.
 
 - 
doGetNextIntermediateResultprotected E doGetNextIntermediateResult(int index, long timeout, boolean realtime) Perform the get without increasing the index.- Overrides:
- doGetNextIntermediateResultin class- IntermediateFuture<E>
 
 
- 
 
-