Interface ActorFuture<V>

All Superinterfaces:
BiConsumer<V,Throwable>, Future<V>
All Known Implementing Classes:
CompletableActorFuture

public interface ActorFuture<V> extends Future<V>, BiConsumer<V,Throwable>
interface for actor futures
  • Method Details

    • complete

      void complete(V value)
    • completeExceptionally

      void completeExceptionally(String failure, Throwable throwable)
    • completeExceptionally

      void completeExceptionally(Throwable throwable)
    • join

      V join()
    • join

      V join(long timeout, TimeUnit timeUnit)
    • block

      void block(ActorTask onCompletion)
      To be used by scheduler only
    • onComplete

      void onComplete(BiConsumer<V,Throwable> consumer)
      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

      default void accept(V value, Throwable throwable)
      Specified by:
      accept in interface BiConsumer<V,Throwable>