Interface ConcurrencyControl

All Superinterfaces:
Executor
All Known Implementing Classes:
Actor, ActorControl

public interface ConcurrencyControl extends Executor
Control interface to schedule tasks or follow-up tasks such that different tasks scheduled via the same ConcurrencyControl object are never executed concurrently
  • Method Details

    • runOnCompletion

      <T> void runOnCompletion(ActorFuture<T> future, BiConsumer<T,Throwable> callback)
      Schedules a callback to be invoked after the future has completed
      Type Parameters:
      T - result type of the future
      Parameters:
      future - the future whose completion is awaited
      callback - the callback to call after the future has completed
    • runOnCompletion

      <T> void runOnCompletion(Collection<ActorFuture<T>> futures, Consumer<Throwable> callback)
      Invoke the callback when the given futures are completed (successfully or exceptionally). This call does not block the actor.

      The callback is executed while the actor is in the following actor lifecycle phases: ActorTask.ActorLifecyclePhase.STARTED

      Parameters:
      futures - the futures to wait on
      callback - The throwable is null when all futures are completed successfully. Otherwise, it holds the exception of the last completed future.
    • run

      void run(Runnable action)
      Schedules an action to be invoked (must be called from an actor thread)
      Parameters:
      action - action to be invoked
    • call

      <T> ActorFuture<T> call(Callable<T> callable)
      Schedules a callable to be executed
      Type Parameters:
      T - type of the result
      Parameters:
      callable - callable to be executed
      Returns:
      a future with the result
    • schedule

      ScheduledTimer schedule(Duration delay, Runnable runnable)
      Schedule a task to be executed after a delay
    • createFuture

      default <V> ActorFuture<V> createFuture()
      Create a new future object
      Type Parameters:
      V - value type of future
      Returns:
      new future object
    • createCompletedFuture

      default <V> ActorFuture<V> createCompletedFuture()
      Create a new completed future object
      Type Parameters:
      V - value type of future
      Returns:
      new completed future object
    • execute

      default void execute(@NotNull @NotNull Runnable command)
      Specified by:
      execute in interface Executor