This trait provides a DSL for writing the inner workings of an actor, e.
Use this trait when defining an akka.actor.Actor with akka.actor.Stash,
since just using actor()(new Act with Stash{})
will not be able to see the
Stash component due to type erasure.
Create an actor with an automatically generated name from the given thunk which must produce an akka.actor.Actor.
Create an actor with an automatically generated name from the given thunk which must produce an akka.actor.Actor.
is an implicit akka.actor.ActorRefFactory, which can either be an akka.actor.ActorSystem or an akka.actor.ActorContext, where the latter is always implicitly available within an akka.actor.Actor.
is a by-name argument which captures an akka.actor.Actor factory; do not make the generated object accessible to code outside and do not return the same object upon subsequent invocations.
Create an actor from the given thunk which must produce an akka.actor.Actor.
Create an actor from the given thunk which must produce an akka.actor.Actor.
is an implicit akka.actor.ActorRefFactory, which can either be an akka.actor.ActorSystem or an akka.actor.ActorContext, where the latter is always implicitly available within an akka.actor.Actor.
is the name, which must be unique within the context of its
parent; defaults to null
which will assign a name automatically.
is a by-name argument which captures an akka.actor.Actor factory; do not make the generated object accessible to code outside and do not return the same object upon subsequent invocations.
Create an actor from the given thunk which must produce an akka.actor.Actor.
Create an actor from the given thunk which must produce an akka.actor.Actor.
is the name, which must be unique within the context of its parent.
is a by-name argument which captures an akka.actor.Actor factory; do not make the generated object accessible to code outside and do not return the same object upon subsequent invocations.
is an implicit akka.actor.ActorRefFactory, which can either be an akka.actor.ActorSystem or an akka.actor.ActorContext, where the latter is always implicitly available within an akka.actor.Actor.
Create an actor from the given thunk which must produce an akka.actor.Actor.
Create an actor from the given thunk which must produce an akka.actor.Actor.
is a by-name argument which captures an akka.actor.Actor factory; do not make the generated object accessible to code outside and do not return the same object upon subsequent invocations.
is an implicit akka.actor.ActorRefFactory, which can either be an akka.actor.ActorSystem or an akka.actor.ActorContext, where the latter is always implicitly available within an akka.actor.Actor.
Create a new actor which will internally queue up messages it gets so that they can be interrogated with the akka.actor.dsl.Inbox!.Inbox!.receive and akka.actor.dsl.Inbox!.Inbox!.select methods.
Create a new actor which will internally queue up messages it gets so that they can be interrogated with the akka.actor.dsl.Inbox!.Inbox!.receive and akka.actor.dsl.Inbox!.Inbox!.select methods. It will be created as a system actor in the ActorSystem which is implicitly (or explicitly) supplied.
This object contains elements which make writing actors and related code more concise, e.g. when trying out actors in the REPL.
For the communication of non-actor code with actors, you may use anonymous actors tailored to this job:
The
receive
andselect
methods are synchronous, i.e. they block the calling thread until an answer from the actor is received or the timeout expires. The default timeout is taken from configuration itemakka.actor.dsl.default-timeout
.When defining actors in the REPL, say, you may want to have a look at the
Act
trait:Note that
actor
can be used with an implicit akka.actor.ActorRefFactory as shown with"barney"
(where the akka.actor.ActorContext serves this purpose), but since nested declarations share the same lexical context"fred"
’s ActorContext would be ambiguous if the akka.actor.ActorSystem were declaredimplicit
(this could also be circumvented by shadowing the namesystem
within"fred"
).Note: If you want to use an
Act with Stash
, you should use theActWithStash
trait in order to have the actor run on a special dispatcher ("akka.actor.default-stash-dispatcher"
) which has the necessary deque-based mailbox setting.