Class FakeActor<Message>

  • All Implemented Interfaces:

    public abstract class FakeActor<Message>
    extends ActorImpl<Message>
    An ActorRef which is not backed by any actual Actor. Instead, this "fake actor" only has a channel that serves as a mailbox, but not no doRun method, or a private strand.
    See Also:
    Serialized Form
    • Constructor Detail

      • FakeActor

        public FakeActor​(java.lang.String name,
                         SendPort<Message> mailbox)
    • Method Detail

      • filterMessage

        protected Message filterMessage​(java.lang.Object m)
        All messages sent to the mailbox are passed to this method. If this method returns a non-null value, this value will be returned from the receive methods. If it returns null, then receive will keep waiting.

        By default, this message passes all LifecycleMessage messages to handleLifecycleMessage, while other messages are returned (and will be returned by receive.

        m - the message
      • addLifecycleListener

        protected void addLifecycleListener​(co.paralleluniverse.actors.LifecycleListener listener)
        Specified by:
        addLifecycleListener in class ActorImpl<Message>
      • getDeathCause

        protected final java.lang.Throwable getDeathCause()
        Returns this actor's cause of death
        the Throwable that caused this actor's death, or null if it died by natural causes, or if it not dead.
      • isDone

        protected final boolean isDone()
        Tests whether this fake actor has terminated.
      • watch

        public final java.lang.Object watch​(ActorRef other)
        Makes this fake actor watch another actor. When the other actor dies, this actor receives an ExitMessage, that is handled by handleLifecycleMessage. This message does not cause an exception to be thrown, unlike the case where it is received as a result of a linked actor's death.

        Unlike a link, a watch is asymmetric, and it is also composable, namely, calling this method twice with the same argument would result in two different values returned, and in an ExitMessage to be received twice.

        other - the other actor
        a watchId object that identifies this watch in messages, and used to remove the watch by the unwatch method.
        See Also:
        unwatch(ActorRef, Object)
      • unwatch

        public final void unwatch​(ActorRef other,
                                  java.lang.Object watchId)
        Un-watches another actor.
        other - the other actor
        watchId - the object returned from the call to watch(other)
        See Also:
      • die

        protected void die​(java.lang.Throwable cause)
      • writeReplace

        protected final java.lang.Object writeReplace()