Class AbstractActorWithLock

  • All Implemented Interfaces:
    akka.actor.Actor, akka.actor.Stash, akka.actor.StashSupport, akka.actor.UnrestrictedStash, akka.dispatch.RequiresMessageQueue<akka.dispatch.DequeBasedMessageQueueSemantics>

    public abstract class AbstractActorWithLock
    extends akka.actor.AbstractActorWithStash
    Actor that can prevent itself from handling messages for a period of time.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class akka.actor.AbstractActor

        akka.actor.AbstractActor.ActorContext, akka.actor.AbstractActor.Receive
      • Nested classes/interfaces inherited from interface akka.actor.Actor

        akka.actor.Actor.emptyBehavior$, akka.actor.Actor.ignoringBehavior$
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void become​(akka.actor.AbstractActor.Receive receive)
      Switches the actor's message handler.
      protected void become​(akka.actor.AbstractActor.Receive receive, boolean discardOld)
      Switches the actor's message handler.
      akka.actor.AbstractActor.Receive createReceive()  
      protected abstract akka.actor.AbstractActor.Receive handleMessage()  
      void postStop()  
      protected void setLocked​(Duration maxLockTime)
      Prevents this actor from handling messages until it gets unlocked.
      protected void unlock()
      Unlocks this actor to handle messages again.
      • Methods inherited from class akka.actor.AbstractActorWithStash

        akka$actor$StashSupport$_setter_$akka$actor$StashSupport$$capacity_$eq, akka$actor$StashSupport$_setter_$mailbox_$eq, akka$actor$StashSupport$$capacity, akka$actor$StashSupport$$theStash, akka$actor$StashSupport$$theStash_$eq, clearStash, mailbox, prepend, preRestart, stash, unstash, unstashAll, unstashAll
      • Methods inherited from class akka.actor.AbstractActor

        akka$actor$Actor$_setter_$context_$eq, akka$actor$Actor$_setter_$self_$eq, aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, context, emptyBehavior, getContext, getSelf, getSender, postRestart, preRestart, preStart, receive, receiveBuilder, self, sender, supervisorStrategy, unhandled
      • Methods inherited from interface akka.actor.Actor

        akka$actor$Actor$_setter_$context_$eq, akka$actor$Actor$_setter_$self_$eq, aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, context, postRestart, preStart, receive, self, sender, supervisorStrategy, unhandled
      • Methods inherited from interface akka.actor.StashSupport

        context, self
    • Constructor Detail

      • AbstractActorWithLock

        protected AbstractActorWithLock()
    • Method Detail

      • handleMessage

        protected abstract akka.actor.AbstractActor.Receive handleMessage()
        Returns:
        Actor's usual message handler. It will always be invoked in the actor's thread.
      • setLocked

        protected void setLocked​(Duration maxLockTime)
        Prevents this actor from handling messages until it gets unlocked.

        This method is NOT thread-safe and MUST be called in the actor's thread!

        Parameters:
        maxLockTime - the maximum time the actor stays locked.
        Throws:
        NullPointerException - if maxLockTime is null.
      • unlock

        protected void unlock()
        Unlocks this actor to handle messages again.

        This method is thread-safe and can be called anywhere.

      • become

        protected void become​(akka.actor.AbstractActor.Receive receive)
        Switches the actor's message handler.

        DO NOT call getContext().become() directly; otherwise the actor loses the ability to lock itself.

        Parameters:
        receive - the new message handler.
      • become

        protected void become​(akka.actor.AbstractActor.Receive receive,
                              boolean discardOld)
        Switches the actor's message handler.

        DO NOT call getContext().become() directly; otherwise the actor loses the ability to lock itself.

        Parameters:
        receive - the new message handler.
        discardOld - whether the old handler should be discarded.
      • createReceive

        public final akka.actor.AbstractActor.Receive createReceive()
        Specified by:
        createReceive in class akka.actor.AbstractActor
      • postStop

        public void postStop()
                      throws Exception
        Specified by:
        postStop in interface akka.actor.Actor
        Specified by:
        postStop in interface akka.actor.UnrestrictedStash
        Overrides:
        postStop in class akka.actor.AbstractActorWithStash
        Throws:
        Exception