Package co.paralleluniverse.actors
Class FakeActor<Message>
- java.lang.Object
-
- co.paralleluniverse.actors.ActorImpl<Message>
-
- co.paralleluniverse.actors.FakeActor<Message>
-
- All Implemented Interfaces:
java.io.Serializable
public abstract class FakeActor<Message> extends ActorImpl<Message>
AnActorRefwhich is not backed by any actualActor. Instead, this "fake actor" only has a channel that serves as a mailbox, but not nodoRunmethod, or a private strand.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class co.paralleluniverse.actors.ActorImpl
ActorImpl.ActorLifecycleListener
-
-
Field Summary
-
Fields inherited from class co.paralleluniverse.actors.ActorImpl
flightRecorder, ref
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddLifecycleListener(co.paralleluniverse.actors.LifecycleListener listener)protected voiddie(java.lang.Throwable cause)protected MessagefilterMessage(java.lang.Object m)All messages sent to the mailbox are passed to this method.protected java.lang.ThrowablegetDeathCause()Returns this actor's cause of deathprotected abstract MessagehandleLifecycleMessage(LifecycleMessage m)protected voidinternalSend(java.lang.Object message)For internal useprotected voidinternalSendNonSuspendable(java.lang.Object message)protected booleanisDone()Tests whether this fake actor has terminated.protected voidremoveLifecycleListener(co.paralleluniverse.actors.LifecycleListener listener)protected voidremoveObserverListeners(ActorRef actor)booleantrySend(Message message)voidunwatch(ActorRef other, java.lang.Object watchId)Un-watches another actor.java.lang.Objectwatch(ActorRef other)Makes this fake actor watch another actor.protected java.lang.ObjectwriteReplace()
-
-
-
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 thereceivemethods. If it returnsnull, thenreceivewill keep waiting.By default, this message passes all
LifecycleMessagemessages tohandleLifecycleMessage, while other messages are returned (and will be returned byreceive.- Parameters:
m- the message
-
internalSend
protected void internalSend(java.lang.Object message) throws SuspendExecutionFor internal use- Specified by:
internalSendin classActorImpl<Message>- Parameters:
message-- Throws:
SuspendExecution
-
internalSendNonSuspendable
protected void internalSendNonSuspendable(java.lang.Object message)
- Specified by:
internalSendNonSuspendablein classActorImpl<Message>
-
addLifecycleListener
protected void addLifecycleListener(co.paralleluniverse.actors.LifecycleListener listener)
- Specified by:
addLifecycleListenerin classActorImpl<Message>
-
getDeathCause
protected final java.lang.Throwable getDeathCause()
Returns this actor's cause of death- Returns:
- the
Throwablethat caused this actor's death, ornullif it died by natural causes, or if it not dead.
-
isDone
protected final boolean isDone()
Tests whether this fake actor has terminated.
-
removeLifecycleListener
protected void removeLifecycleListener(co.paralleluniverse.actors.LifecycleListener listener)
- Specified by:
removeLifecycleListenerin classActorImpl<Message>
-
removeObserverListeners
protected void removeObserverListeners(ActorRef actor)
- Specified by:
removeObserverListenersin classActorImpl<Message>
-
watch
public final java.lang.Object watch(ActorRef other)
Makes this fake actor watch another actor. When the other actor dies, this actor receives anExitMessage, that is handled byhandleLifecycleMessage. 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
ExitMessageto be received twice.- Parameters:
other- the other actor- Returns:
- a
watchIdobject that identifies this watch in messages, and used to remove the watch by theunwatchmethod. - See Also:
unwatch(ActorRef, Object)
-
unwatch
public final void unwatch(ActorRef other, java.lang.Object watchId)
Un-watches another actor.- Parameters:
other- the other actorwatchId- the object returned from the call towatch(other)- See Also:
watch(ActorRef)
-
handleLifecycleMessage
protected abstract Message handleLifecycleMessage(LifecycleMessage m)
-
die
protected void die(java.lang.Throwable cause)
-
writeReplace
protected final java.lang.Object writeReplace() throws java.io.ObjectStreamException- Throws:
java.io.ObjectStreamException
-
-