Package akka.actor

Class FunctionRef

  • All Implemented Interfaces:
    ActorRefScope, LocalRef, MinimalActorRef, ScalaActorRef, java.io.Serializable, java.lang.Comparable<ActorRef>

    public final class FunctionRef
    extends InternalActorRef
    implements MinimalActorRef
    INTERNAL API

    This kind of ActorRef passes all received messages to the given function for performing a non-blocking side-effect. The intended use is to transform the message before sending to the real target actor. Such references can be created by calling ActorCell.addFunctionRef and must be deregistered when no longer needed by calling ActorCell.removeFunctionRef. FunctionRefs do not count towards the live children of an actor, they do not receive the Terminate command and do not prevent the parent from terminating. FunctionRef is properly registered for remote lookup and ActorSelection.

    It can both be watched by other actors and also watch(akka.actor.ActorRef) other actors. When watching other actors and upon receiving the Terminated message, unwatch(akka.actor.ActorRef) must be called to avoid a resource leak, which is different from an ordinary actor.

    See Also:
    Serialized Form
    • Method Detail

      • deadLetterMessageHandler

        public static scala.Function2<ActorRef,​java.lang.Object,​scala.runtime.BoxedUnit> deadLetterMessageHandler​(ActorSystem system)
      • path

        public ActorPath path()
        Description copied from class: ActorRef
        Returns the path for this actor (from this actor up to the root actor).
        Specified by:
        path in class ActorRef
      • $bang

        public void $bang​(java.lang.Object message,
                          ActorRef sender)
        Description copied from class: ActorRef
        Scala API: Sends a one-way asynchronous message. E.g. fire-and-forget semantics.

        If invoked from within an actor then the actor reference is implicitly passed on as the implicit 'sender' argument.

        This actor 'sender' reference is then available in the receiving actor in the 'sender()' member variable, if invoked from within an Actor. If not then no sender is available.

           actor ! message
         

        Specified by:
        $bang in interface MinimalActorRef
        Specified by:
        $bang in interface ScalaActorRef
        Specified by:
        $bang in class ActorRef
      • sendTerminated

        protected void sendTerminated()
      • watch

        public void watch​(ActorRef actorRef)
        Have this FunctionRef watch the given Actor.

        Upon receiving the Terminated message, unwatch must be called to avoid resource leak, which is different from an ordinary actor.

      • unwatch

        public void unwatch​(ActorRef actorRef)
        Have this FunctionRef unwatch the given Actor.

        Upon receiving the Terminated message, unwatch must be called to avoid resource leak, which is different from an ordinary actor.

      • isWatching

        public boolean isWatching​(ActorRef actorRef)
        Query whether this FunctionRef is currently watching the given Actor.