Class SubscriptionIntermediateFuture<E>

    • Field Detail

      • ownresults

        protected java.util.Map<java.lang.Thread,​java.util.List<E>> ownresults
        The local results for a single thread.
      • storeforfirst

        protected boolean storeforfirst
        Flag if results should be stored till first listener is added.
      • resultssize

        protected int resultssize
        The number of results.
    • Constructor Detail

      • SubscriptionIntermediateFuture

        public SubscriptionIntermediateFuture()
        Create a new future.
      • SubscriptionIntermediateFuture

        public SubscriptionIntermediateFuture​(java.lang.Exception exception)
        Create a future that is already done (failed).
        Parameters:
        exception - The exception.
      • SubscriptionIntermediateFuture

        public SubscriptionIntermediateFuture​(ITerminationCommand terminate)
        Create a new future.
        Parameters:
        terminate - The code to be executed in case of termination.
      • SubscriptionIntermediateFuture

        public SubscriptionIntermediateFuture​(ITerminationCommand terminate,
                                              boolean storeforfirst)
        Create a new future.
        Parameters:
        terminate - The code to be executed in case of termination.
    • Method Detail

      • storeResult

        protected boolean storeResult​(E result)
        Store a result.
        Overrides:
        storeResult in class IntermediateFuture<E>
        Parameters:
        result - The result.
      • getResultCount

        protected int getResultCount()
        Get the number of results already collected.
        Overrides:
        getResultCount in class IntermediateFuture<E>
        Returns:
        The number of results.
      • addQuietListener

        public 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:
        addQuietListener in interface ISubscriptionIntermediateFuture<E>
      • getNextIntermediateResult

        public 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:
        getNextIntermediateResult in interface IIntermediateFuture<E>
        Overrides:
        getNextIntermediateResult in 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.
      • hasNextIntermediateResult

        public 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:
        hasNextIntermediateResult in interface IIntermediateFuture<E>
        Overrides:
        hasNextIntermediateResult in 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.
      • doGetNextIntermediateResult

        protected E doGetNextIntermediateResult​(int index,
                                                long timeout,
                                                boolean realtime)
        Perform the get without increasing the index.
        Overrides:
        doGetNextIntermediateResult in class IntermediateFuture<E>