Class CompletableActorFuture<V>
java.lang.Object
io.camunda.zeebe.util.sched.future.CompletableActorFuture<V>
- All Implemented Interfaces:
ActorFuture<V>,Future<V>,BiConsumer<V,Throwable>
Completable future implementation that is garbage free and reusable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidTo be used by scheduler onlybooleancancel(boolean mayInterruptIfRunning) booleanclose()future is reusable after closevoidstatic <V> CompletableActorFuture<V>completed(V result) static <V> CompletableActorFuture<V>completedExceptionally(Throwable throwable) voidcompleteExceptionally(String failure, Throwable throwable) voidcompleteExceptionally(Throwable throwable) voidcompleteWith(CompletableActorFuture<V> otherFuture) get()booleanbooleanbooleanisClosed()booleanbooleanisDone()join()voidonComplete(BiConsumer<V, Throwable> consumer) Registers an consumer, which is executed after the future was completed.voidtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.camunda.zeebe.util.sched.future.ActorFuture
acceptMethods inherited from interface java.util.function.BiConsumer
andThen
-
Constructor Details
-
CompletableActorFuture
public CompletableActorFuture()
-
-
Method Details
-
setAwaitingResult
public void setAwaitingResult() -
completed
-
completedExceptionally
-
cancel
public boolean cancel(boolean mayInterruptIfRunning) -
isCancelled
public boolean isCancelled()- Specified by:
isCancelledin interfaceFuture<V>
-
isDone
public boolean isDone() -
get
- Specified by:
getin interfaceFuture<V>- Throws:
ExecutionExceptionInterruptedException
-
get
public V get(long timeout, TimeUnit unit) throws ExecutionException, TimeoutException, InterruptedException - Specified by:
getin interfaceFuture<V>- Throws:
ExecutionExceptionTimeoutExceptionInterruptedException
-
isAwaitingResult
public boolean isAwaitingResult() -
complete
- Specified by:
completein interfaceActorFuture<V>
-
completeExceptionally
- Specified by:
completeExceptionallyin interfaceActorFuture<V>
-
completeExceptionally
- Specified by:
completeExceptionallyin interfaceActorFuture<V>
-
join
- Specified by:
joinin interfaceActorFuture<V>
-
join
- Specified by:
joinin interfaceActorFuture<V>
-
block
Description copied from interface:ActorFutureTo be used by scheduler only- Specified by:
blockin interfaceActorFuture<V>
-
onComplete
Description copied from interface:ActorFutureRegisters an consumer, which is executed after the future was completed. The consumer is executed in the current actor thread, which is used to register the consumer.Example:
Actor A calls Actor B to retrieve an value. Actor B returns an future, which will be completed later with the right value. Actor A wants to do some work, after B returns the value. For that Actor A calls `#onComplete`, at this returned future, to register an consumer. After the future is completed, the registered consumer is called in the Actor A context.
Running in Actor A context:
final ActorFuture
future = ActorB.getValue(); future.onComplete(value, throwable -> { // do things - runs in Actor A context again }); - Specified by:
onCompletein interfaceActorFuture<V>- Parameters:
consumer- the consumer which should be called after the future was completed
-
isCompletedExceptionally
public boolean isCompletedExceptionally()- Specified by:
isCompletedExceptionallyin interfaceActorFuture<V>
-
getException
- Specified by:
getExceptionin interfaceActorFuture<V>
-
close
public boolean close()future is reusable after close -
isClosed
public boolean isClosed() -
completeWith
-
toString
-