net.tomp2p.futures
Class FutureLaterJoin<K extends BaseFuture>

java.lang.Object
  extended by net.tomp2p.futures.BaseFutureImpl<FutureLaterJoin<K>>
      extended by net.tomp2p.futures.FutureLaterJoin<K>
Type Parameters:
K -
All Implemented Interfaces:
BaseFuture, Cancellable

public class FutureLaterJoin<K extends BaseFuture>
extends BaseFutureImpl<FutureLaterJoin<K>>
implements BaseFuture

FutureLaterJoin is similar to FutureLateJoin. The main difference is that with this class you don't need to specify all the futures in advance and you don't need to specify how many futures you expect. Once you are done, just call done().

Author:
Thomas Bocek

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.tomp2p.futures.BaseFuture
BaseFuture.FutureType
 
Field Summary
 
Fields inherited from class net.tomp2p.futures.BaseFutureImpl
completed, lock, reason, type
 
Constructor Summary
FutureLaterJoin()
          Create this future.
 
Method Summary
 boolean add(K future)
          Add a future when ready.
 void done()
          If no more futures are added, done() must be called to evaluate the results.
 void done(int minSuccess)
          If no more futures are added, done() must be called to evaluate the results.
 List<K> getFuturesDone()
          Returns the finished futures.
 K getLastSuceessFuture()
           
 
Methods inherited from class net.tomp2p.futures.BaseFutureImpl
addCancellation, addListener, addListener, await, await, awaitListeners, awaitUninterruptibly, awaitUninterruptibly, cancel, getFailedReason, getType, isCompleted, isFailed, isSuccess, notifyListerenrs, removeListener, self, setCompletedAndNotify, setFailed, setFailed, setFailed, setFailed, setFailed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.tomp2p.futures.BaseFuture
addCancellation, addListener, addListener, await, await, awaitListeners, awaitUninterruptibly, awaitUninterruptibly, getFailedReason, getType, isCompleted, isFailed, isSuccess, removeListener, setFailed, setFailed, setFailed, setFailed, setFailed
 
Methods inherited from interface net.tomp2p.futures.Cancellable
cancel
 

Constructor Detail

FutureLaterJoin

public FutureLaterJoin()
Create this future.

Method Detail

add

public boolean add(K future)
Add a future when ready. This is why its called FutureLateJoin, since you can add futures later on.

Parameters:
future - The future to be added.
Returns:
True if the future was added to the futurelist, false if the latejoin future is already finished and the future was not added.

done

public void done()
If no more futures are added, done() must be called to evaluate the results. If the futures already finished by the time done() is called, the listeners are called from this thread. Otherwise the notify may be called from a different thread.


done

public void done(int minSuccess)
If no more futures are added, done() must be called to evaluate the results. If the futures already finished by the time done() is called, the listeners are called from this thread. Otherwise the notify may be called from a different thread.

Parameters:
minSuccess - The number of minimum futures that needs to be successful to consider this future as a success.

getFuturesDone

public List<K> getFuturesDone()
Returns the finished futures.

Returns:
All the futures that are done.

getLastSuceessFuture

public K getLastSuceessFuture()
Returns:
the last successful finished future.


Copyright © 2013. All Rights Reserved.