|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ActorContext
The actor context - the view of the actor cell from the actor. Exposes contextual information for the actor and the current message.
There are several possibilities for creating actors (see Props
for details on props
):
// Java or Scala
context.actorOf(props, "name")
context.actorOf(props)
// Scala
context.actorOf(Props[MyActor])
context.actorOf(Props(classOf[MyActor], arg1, arg2), "name")
// Java
getContext().actorOf(Props.create(MyActor.class));
getContext().actorOf(Props.create(MyActor.class, arg1, arg2), "name");
Where no name is given explicitly, one will be automatically generated.
Method Summary | |
---|---|
void |
become(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> behavior,
boolean discardOld)
Changes the Actor's behavior to become the new 'Receive' (PartialFunction[Any, Unit]) handler. |
scala.Option<ActorRef> |
child(java.lang.String name)
Get the child with the given name if it exists. |
scala.collection.immutable.Iterable<ActorRef> |
children()
Returns all supervised children; this method returns a view (i.e. |
scala.concurrent.ExecutionContext |
dispatcher()
Returns the dispatcher (MessageDispatcher) that is used for this Actor. |
ActorRef |
parent()
Returns the supervising parent ActorRef. |
Props |
props()
Retrieve the Props which were used to create this actor. |
scala.concurrent.duration.Duration |
receiveTimeout()
Gets the current receive timeout. |
ActorRef |
self()
|
ActorRef |
sender()
Returns the sender 'ActorRef' of the current message. |
void |
setReceiveTimeout(scala.concurrent.duration.Duration timeout)
Defines the inactivity timeout after which the sending of a ReceiveTimeout message is triggered. |
ActorSystem |
system()
The system that the actor belongs to. |
void |
unbecome()
Reverts the Actor behavior to the previous one in the hotswap stack. |
ActorRef |
unwatch(ActorRef subject)
Unregisters this actor as Monitor for the provided ActorRef. |
ActorRef |
watch(ActorRef subject)
Registers this actor as a Monitor for the provided ActorRef. |
void |
writeObject(java.io.ObjectOutputStream o)
ActorContexts shouldn't be Serializable |
Methods inherited from interface akka.actor.ActorRefFactory |
---|
actorFor, actorFor, actorFor, actorFor, actorOf, actorOf, actorSelection, actorSelection, guardian, lookupRoot, provider, stop, systemImpl |
Method Detail |
---|
ActorRef self()
Props props()
scala.concurrent.duration.Duration receiveTimeout()
ReceiveTimeout
message.
void setReceiveTimeout(scala.concurrent.duration.Duration timeout)
ReceiveTimeout
message is triggered.
When specified, the receive function should be able to handle a ReceiveTimeout
message.
1 millisecond is the minimum supported timeout.
Please note that the receive timeout might fire and enqueue the ReceiveTimeout
message right after
another message was enqueued; hence it is '''not guaranteed''' that upon reception of the receive
timeout there must have been an idle period beforehand as configured via this method.
Once set, the receive timeout stays in effect (i.e. continues firing repeatedly after inactivity
periods). Pass in Duration.Undefined
to switch off this feature.
void become(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> behavior, boolean discardOld)
- if discardOld = true
it will replace the top element (i.e. the current behavior)
- if discardOld = false
it will keep the current behavior and push the given one atop
The default of replacing the current behavior has been chosen to avoid memory leaks in
case client code is written without consulting this documentation first (i.e. always pushing
new closures and never issuing an unbecome()
)
void unbecome()
ActorRef sender()
scala.collection.immutable.Iterable<ActorRef> children()
child
instead for performance reasons:
val badLookup = context.children find (_.path.name == "kid")
// should better be expressed as:
val goodLookup = context.child("kid")
scala.Option<ActorRef> child(java.lang.String name)
scala.concurrent.ExecutionContext dispatcher()
dispatcher
in interface ActorRefFactory
ActorSystem system()
ActorRef parent()
ActorRef watch(ActorRef subject)
ActorRef unwatch(ActorRef subject)
void writeObject(java.io.ObjectOutputStream o)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |