Package akka.actor

Class FunctionRef

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

    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

      • $bang

        public void $bang​(java.lang.Object message,
                          ActorRef sender)
        Description copied from interface: ScalaActorRef
        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
        Parameters:
        message - (undocumented)
        sender - (undocumented)
      • isTerminated

        public boolean isTerminated()
        Description copied from class: InternalActorRef
        INTERNAL API: Returns &ldquo;true&rdquo; if the actor is locally known to be terminated, &ldquo;false&rdquo; if alive or uncertain.
        Specified by:
        isTerminated in interface MinimalActorRef
        Specified by:
        isTerminated in class InternalActorRef
        Returns:
        (undocumented)
      • isWatching

        public boolean isWatching​(ActorRef actorRef)
        Query whether this FunctionRef is currently watching the given Actor.
        Parameters:
        actorRef - (undocumented)
        Returns:
        (undocumented)
      • 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
        Returns:
        (undocumented)
      • sendTerminated

        protected void sendTerminated()
      • 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.

        Parameters:
        actorRef - (undocumented)
      • 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.

        Parameters:
        actorRef - (undocumented)