Allow different types of mailboxes on the same dispatcher. See #2687

This commit is contained in:
Björn Antonsson 2013-04-18 13:35:36 +02:00
parent c86cc0b8f7
commit c3eed374f1
32 changed files with 735 additions and 74 deletions

View file

@ -10,7 +10,7 @@ import scala.reflect.ClassTag
import akka.routing._
import akka.util.Reflect
import scala.annotation.varargs
import Deploy.NoDispatcherGiven
import Deploy.{ NoDispatcherGiven, NoMailboxGiven }
import scala.collection.immutable
/**
@ -177,6 +177,15 @@ case class Props(deploy: Deploy, clazz: Class[_], args: immutable.Seq[Any]) {
case x x
}
/**
* Convenience method for extracting the mailbox information from the
* contained [[Deploy]] instance.
*/
def mailbox: Option[String] = deploy.mailbox match {
case NoMailboxGiven None
case x Some(x)
}
/**
* Convenience method for extracting the router configuration from the
* contained [[Deploy]] instance.
@ -218,6 +227,11 @@ case class Props(deploy: Deploy, clazz: Class[_], args: immutable.Seq[Any]) {
*/
def withDispatcher(d: String): Props = copy(deploy = deploy.copy(dispatcher = d))
/**
* Returns a new Props with the specified mailbox set.
*/
def withMailbox(m: String): Props = copy(deploy = deploy.copy(mailbox = m))
/**
* Returns a new Props with the specified router config set.
*/
@ -309,3 +323,11 @@ private[akka] class CreatorConsumer(creator: Creator[Actor]) extends IndirectAct
override def actorClass = classOf[Actor]
override def produce() = creator.create()
}
/**
* INTERNAL API
*/
private[akka] class TypedCreatorFunctionConsumer(clz: Class[_ <: Actor], creator: () Actor) extends IndirectActorProducer {
override def actorClass = clz
override def produce() = creator()
}