Interface ActorFuture<V>
- All Superinterfaces:
BiConsumer<V,,Throwable> Future<V>
- All Known Implementing Classes:
CompletableActorFuture
interface for actor futures
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidvoidTo be used by scheduler onlyvoidvoidcompleteExceptionally(String failure, Throwable throwable) voidcompleteExceptionally(Throwable throwable) booleanjoin()voidonComplete(BiConsumer<V, Throwable> consumer) Registers an consumer, which is executed after the future was completed.Methods inherited from interface java.util.function.BiConsumer
andThen
-
Method Details
-
complete
-
completeExceptionally
-
completeExceptionally
-
join
V join() -
join
-
block
To be used by scheduler only -
onComplete
Registers 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 }); - Parameters:
consumer- the consumer which should be called after the future was completed- Throws:
UnsupportedOperationException- when not called on actor thread
-
isCompletedExceptionally
boolean isCompletedExceptionally() -
getException
Throwable getException() -
accept
- Specified by:
acceptin interfaceBiConsumer<V,Throwable>
-