Class Cascade.AbstractStage

java.lang.Object
com.mackenziehigh.cascade.Cascade.AbstractStage
All Implemented Interfaces:
Cascade.Stage
Enclosing interface:
Cascade

public abstract static class Cascade.AbstractStage extends Object implements Cascade.Stage
Partial Implementation of Stage.
  • Constructor Details

    • AbstractStage

      public AbstractStage()
  • Method Details

    • onRunnable

      protected abstract void onRunnable(Cascade.AbstractStage.DefaultActor<?,?> actor)
      This method will be invoked whenever an actor needs executed.

      This method will not be re-invoked, until the actor finishes being executed, even if the actor determines that it needs to be executed again. Rather, the actor will invoke this method again, if needed, at the end of its execution. This strategy helps ensure that no two threads will ever power the actor concurrently. Moreover, this strategy lessons the amount of memory used by some implementations in order to schedule actors.

      Implementations of this method should never throw exceptions. If an exception or error is thrown, then the stage will be closed.

      Parameters:
      actor - needs to be run() at some point in the future.
    • onClose

      protected abstract void onClose()
      This method will be invoked when this stage closes.
    • newActor

      public final <I, O> Cascade.Stage.Actor.Builder<I,O> newActor()
      Create a builder that can be used to add a new actor to this stage.

      This method returns a builder, rather than an actor itself, so that further configuration of the actor can be performed, if the calling code so desires.

      Specified by:
      newActor in interface Cascade.Stage
      Type Parameters:
      I - is the type of messages that the actor will consume.
      O - is the type of messages that the actor will produce.
      Returns:
      the new builder.
    • close

      public final void close()
      Asynchronously shutdown this stage, as soon as reasonably possible.

      Subsequent invocations of this method are idempotent.

      Specified by:
      close in interface Cascade.Stage