Class ActorDSL$

  extended by akka.actor.ActorDSL$
All Implemented Interfaces:
Creators, Inbox

public class ActorDSL$
extends java.lang.Object
implements Inbox, Creators

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:

 import ActorDSL._
 import scala.concurrent.util.duration._

 implicit val system: ActorSystem = ...

 implicit val i = inbox()
 someActor ! someMsg // replies will go to `i`

 val reply = i.receive()
 val transformedReply = i.select(5 seconds) {
   case x: Int => 2 * x

The receive and select 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 item akka.actor.dsl.default-timeout.

When defining actors in the REPL, say, you may want to have a look at the Act trait:

 import ActorDSL._

 val system: ActorSystem = ...

 val a = actor(system, "fred")(new Act {
     val b = actor("barney")(new Act {

     become {
       case msg => ...

Note that actor can be used with an implicit ActorRefFactory as shown with "barney" (where the ActorContext serves this purpose), but since nested declarations share the same lexical context "fred"’s ActorContext would be ambiguous if the ActorSystem were declared implicit (this could also be circumvented by shadowing the name system within "fred").

Note: If you want to use an Act with Stash, you should use the ActWithStash trait in order to have the actor get the necessary deque-based mailbox setting.

Nested Class Summary
Nested classes/interfaces inherited from interface akka.actor.dsl.Inbox
Inbox.Get, Inbox.Get$, Inbox.Inbox, Inbox.InboxExtension, Inbox.Kick$, Inbox.Query, Inbox.Select, Inbox.Select$, Inbox.StartWatch, Inbox.StartWatch$
Nested classes/interfaces inherited from interface akka.actor.dsl.Creators
Creators.Act, Creators.ActWithStash
Field Summary
static ActorDSL$ MODULE$
          Static reference to the singleton instance of this Scala object.
Constructor Summary
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface akka.actor.dsl.Inbox
deadlineOrder, extraTime, inbox, senderFromInbox
Methods inherited from interface akka.actor.dsl.Creators
actor, actor, actor, actor, mkProps

Field Detail


public static final ActorDSL$ MODULE$
Static reference to the singleton instance of this Scala object.

Constructor Detail


public ActorDSL$()