public final class FunctionRef extends InternalActorRef implements MinimalActorRef
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.
When using the watch() feature you must ensure that upon reception of the Terminated message the watched actorRef is unwatch()ed.
Constructor and Description |
---|
FunctionRef(ActorPath path,
ActorRefProvider provider,
EventStream eventStream,
scala.Function2<ActorRef,java.lang.Object,scala.runtime.BoxedUnit> f) |
Modifier and Type | Method and Description |
---|---|
EventStream |
eventStream() |
boolean |
isTerminated()
INTERNAL API: Returns “true” if the actor is locally known to be terminated, “false” if
alive or uncertain.
|
boolean |
isWatching(ActorRef actorRef)
Query whether this FunctionRef is currently watching the given Actor.
|
ActorPath |
path()
Returns the path for this actor (from this actor up to the root actor).
|
ActorRefProvider |
provider()
Get a reference to the actor ref provider which created this ref.
|
void |
sendSystemMessage(SystemMessage message) |
protected void |
sendTerminated() |
void |
stop() |
void |
unwatch(ActorRef actorRef)
Have this FunctionRef unwatch the given Actor.
|
void |
watch(ActorRef actorRef)
Have this FunctionRef watch the given Actor.
|
getChild, getParent, isLocal, restart, resume, start, suspend
compareTo, equals, forward, hashCode, noSender, tell, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getChild, getParent, restart, resume, start, suspend, writeReplace
public FunctionRef(ActorPath path, ActorRefProvider provider, EventStream eventStream, scala.Function2<ActorRef,java.lang.Object,scala.runtime.BoxedUnit> f)
public ActorPath path()
ActorRef
public ActorRefProvider provider()
InternalActorRef
provider
in class InternalActorRef
public EventStream eventStream()
public void sendSystemMessage(SystemMessage message)
sendSystemMessage
in interface MinimalActorRef
sendSystemMessage
in class InternalActorRef
public boolean isTerminated()
InternalActorRef
isTerminated
in interface MinimalActorRef
isTerminated
in class InternalActorRef
protected void sendTerminated()
public void stop()
stop
in interface MinimalActorRef
stop
in class InternalActorRef
public void watch(ActorRef actorRef)
Upon receiving the Terminated message, unwatch() must be called from a safe context (i.e. normally from the parent Actor).
actorRef
- (undocumented)public void unwatch(ActorRef actorRef)
actorRef
- (undocumented)public boolean isWatching(ActorRef actorRef)
actorRef
- (undocumented)