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>
AnActorRef
which is not backed by any actualActor
. Instead, this "fake actor" only has a channel that serves as a mailbox, but not nodoRun
method, 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 void
addLifecycleListener(co.paralleluniverse.actors.LifecycleListener listener)
protected void
die(java.lang.Throwable cause)
protected Message
filterMessage(java.lang.Object m)
All messages sent to the mailbox are passed to this method.protected java.lang.Throwable
getDeathCause()
Returns this actor's cause of deathprotected abstract Message
handleLifecycleMessage(LifecycleMessage m)
protected void
internalSend(java.lang.Object message)
For internal useprotected void
internalSendNonSuspendable(java.lang.Object message)
protected boolean
isDone()
Tests whether this fake actor has terminated.protected void
removeLifecycleListener(co.paralleluniverse.actors.LifecycleListener listener)
protected void
removeObserverListeners(ActorRef actor)
boolean
trySend(Message message)
void
unwatch(ActorRef other, java.lang.Object watchId)
Un-watches another actor.java.lang.Object
watch(ActorRef other)
Makes this fake actor watch another actor.protected java.lang.Object
writeReplace()
-
-
-
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 thereceive
methods. If it returnsnull
, thenreceive
will keep waiting.By default, this message passes all
LifecycleMessage
messages tohandleLifecycleMessage
, while other messages are returned (and will be returned byreceive
.- Parameters:
m
- the message
-
internalSend
protected void internalSend(java.lang.Object message) throws SuspendExecution
For internal use- Specified by:
internalSend
in classActorImpl<Message>
- Parameters:
message
-- Throws:
SuspendExecution
-
internalSendNonSuspendable
protected void internalSendNonSuspendable(java.lang.Object message)
- Specified by:
internalSendNonSuspendable
in classActorImpl<Message>
-
addLifecycleListener
protected void addLifecycleListener(co.paralleluniverse.actors.LifecycleListener listener)
- Specified by:
addLifecycleListener
in classActorImpl<Message>
-
getDeathCause
protected final java.lang.Throwable getDeathCause()
Returns this actor's cause of death- Returns:
- the
Throwable
that caused this actor's death, ornull
if 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:
removeLifecycleListener
in classActorImpl<Message>
-
removeObserverListeners
protected void removeObserverListeners(ActorRef actor)
- Specified by:
removeObserverListeners
in 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
ExitMessage
to be received twice.- Parameters:
other
- the other actor- Returns:
- a
watchId
object that identifies this watch in messages, and used to remove the watch by theunwatch
method. - 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
-
-