Package com.yahoo.jdisc.handler
Class FutureConjunction
- java.lang.Object
-
- com.yahoo.jdisc.handler.FutureConjunction
-
- All Implemented Interfaces:
com.google.common.util.concurrent.ListenableFuture<Boolean>
,Future<Boolean>
public final class FutureConjunction extends Object implements com.google.common.util.concurrent.ListenableFuture<Boolean>
This class implements a Future<Boolean> that is conjunction of zero or more other Future<Boolean>s, i.e. it evaluates to
TODO: consider rewriting usage of FutureConjunction to use CompletableFuture instead.true
if, and only if, all its operands evaluate totrue
. To use this class, simply create an instance of it and add operands to it using theaddOperand(ListenableFuture)
method.- Author:
- Simon Thoresen Hult
-
-
Constructor Summary
Constructors Constructor Description FutureConjunction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(Runnable listener, Executor executor)
void
addOperand(com.google.common.util.concurrent.ListenableFuture<Boolean> operand)
Adds a ListenableFuture<Boolean> to this conjunction.boolean
cancel(boolean mayInterruptIfRunning)
Boolean
get()
Boolean
get(long timeout, TimeUnit unit)
boolean
isCancelled()
boolean
isDone()
-
-
-
Method Detail
-
addOperand
public void addOperand(com.google.common.util.concurrent.ListenableFuture<Boolean> operand)
Adds a ListenableFuture<Boolean> to this conjunction. This can be called at any time, even after having called
get()
previously.- Parameters:
operand
- The operand to add to this conjunction.
-
addListener
public void addListener(Runnable listener, Executor executor)
- Specified by:
addListener
in interfacecom.google.common.util.concurrent.ListenableFuture<Boolean>
-
cancel
public final boolean cancel(boolean mayInterruptIfRunning)
-
isCancelled
public final boolean isCancelled()
- Specified by:
isCancelled
in interfaceFuture<Boolean>
-
get
public final Boolean get() throws InterruptedException, ExecutionException
- Specified by:
get
in interfaceFuture<Boolean>
- Throws:
InterruptedException
ExecutionException
-
get
public final Boolean get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
- Specified by:
get
in interfaceFuture<Boolean>
- Throws:
InterruptedException
ExecutionException
TimeoutException
-
-