Package com.yahoo.jdisc.handler
Class FutureConjunction
- java.lang.Object
-
- com.yahoo.jdisc.handler.FutureConjunction
-
- All Implemented Interfaces:
com.google.common.util.concurrent.ListenableFuture<java.lang.Boolean>
,java.util.concurrent.Future<java.lang.Boolean>
public final class FutureConjunction extends java.lang.Object implements com.google.common.util.concurrent.ListenableFuture<java.lang.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(java.lang.Runnable listener, java.util.concurrent.Executor executor)
void
addOperand(com.google.common.util.concurrent.ListenableFuture<java.lang.Boolean> operand)
Adds a ListenableFuture<Boolean> to this conjunction.boolean
cancel(boolean mayInterruptIfRunning)
java.lang.Boolean
get()
java.lang.Boolean
get(long timeout, java.util.concurrent.TimeUnit unit)
boolean
isCancelled()
boolean
isDone()
-
-
-
Method Detail
-
addOperand
public void addOperand(com.google.common.util.concurrent.ListenableFuture<java.lang.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(java.lang.Runnable listener, java.util.concurrent.Executor executor)
- Specified by:
addListener
in interfacecom.google.common.util.concurrent.ListenableFuture<java.lang.Boolean>
-
cancel
public final boolean cancel(boolean mayInterruptIfRunning)
- Specified by:
cancel
in interfacejava.util.concurrent.Future<java.lang.Boolean>
-
isCancelled
public final boolean isCancelled()
- Specified by:
isCancelled
in interfacejava.util.concurrent.Future<java.lang.Boolean>
-
isDone
public final boolean isDone()
- Specified by:
isDone
in interfacejava.util.concurrent.Future<java.lang.Boolean>
-
get
public final java.lang.Boolean get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
- Specified by:
get
in interfacejava.util.concurrent.Future<java.lang.Boolean>
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
-
get
public final java.lang.Boolean get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
- Specified by:
get
in interfacejava.util.concurrent.Future<java.lang.Boolean>
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
-
-