cz.cuni.amis.utils.future
Class CombinedBooleanFuture

java.lang.Object
  extended by cz.cuni.amis.utils.future.CombinedBooleanFuture
All Implemented Interfaces:
IFuture<java.lang.Boolean>, java.util.concurrent.Future<java.lang.Boolean>

public class CombinedBooleanFuture
extends java.lang.Object
implements IFuture<java.lang.Boolean>

Used to combine multiple Future<Boolean> together into one Future<Boolean>.

During construction of the instance of this class you have to specify an array of booleans you want to combine - then all methods will wait for all futures to end (e.g. get(), etc.).

Note that you will probably want to use getAll() method to get respective Future results.


Constructor Summary
CombinedBooleanFuture(IFuture<java.lang.Boolean>[] futures)
           
 
Method Summary
 boolean cancel(boolean mayInterruptIfRunning)
           
 java.lang.Boolean get()
          Waits if necessary for the computation to complete, and then retrieves its result.
 java.lang.Boolean get(long timeout, java.util.concurrent.TimeUnit unit)
          Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.
 java.lang.Boolean[] getAll(long timeout, java.util.concurrent.TimeUnit unit)
           
 java.util.concurrent.Future<java.lang.Boolean>[] getFutures()
           
 boolean isCancelled()
           
 boolean isDone()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CombinedBooleanFuture

public CombinedBooleanFuture(IFuture<java.lang.Boolean>[] futures)
Method Detail

cancel

public boolean cancel(boolean mayInterruptIfRunning)
Specified by:
cancel in interface java.util.concurrent.Future<java.lang.Boolean>

get

public java.lang.Boolean get()
Description copied from interface: IFuture
Waits if necessary for the computation to complete, and then retrieves its result.

Specified by:
get in interface IFuture<java.lang.Boolean>
Specified by:
get in interface java.util.concurrent.Future<java.lang.Boolean>
Returns:
the computed result

get

public java.lang.Boolean get(long timeout,
                             java.util.concurrent.TimeUnit unit)
Description copied from interface: IFuture
Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.

Specified by:
get in interface IFuture<java.lang.Boolean>
Specified by:
get in interface java.util.concurrent.Future<java.lang.Boolean>
Parameters:
timeout - the maximum time to wait
unit - the time unit of the timeout argument
Returns:
the computed result

getAll

public java.lang.Boolean[] getAll(long timeout,
                                  java.util.concurrent.TimeUnit unit)

isCancelled

public boolean isCancelled()
Specified by:
isCancelled in interface java.util.concurrent.Future<java.lang.Boolean>

isDone

public boolean isDone()
Specified by:
isDone in interface java.util.concurrent.Future<java.lang.Boolean>

getFutures

public java.util.concurrent.Future<java.lang.Boolean>[] getFutures()