+act #3246 Added control aware mailbox types
This commit is contained in:
parent
dfef14a590
commit
c3950a7525
8 changed files with 414 additions and 0 deletions
|
|
@ -175,6 +175,14 @@ object DispatcherDocSpec {
|
|||
mailbox-type = "docs.dispatcher.MyUnboundedMailbox"
|
||||
}
|
||||
//#custom-mailbox-config
|
||||
|
||||
//#control-aware-mailbox-config
|
||||
control-aware-dispatcher {
|
||||
mailbox-type = "akka.dispatch.UnboundedControlAwareMailbox"
|
||||
//Other dispatcher configuration goes here
|
||||
}
|
||||
//#control-aware-mailbox-config
|
||||
|
||||
"""
|
||||
|
||||
//#prio-mailbox
|
||||
|
|
@ -202,6 +210,12 @@ object DispatcherDocSpec {
|
|||
})
|
||||
//#prio-mailbox
|
||||
|
||||
//#control-aware-mailbox-messages
|
||||
import akka.dispatch.ControlMessage
|
||||
|
||||
case object MyControlMessage extends ControlMessage
|
||||
//#control-aware-mailbox-messages
|
||||
|
||||
class MyActor extends Actor {
|
||||
def receive = {
|
||||
case x =>
|
||||
|
|
@ -331,6 +345,39 @@ class DispatcherDocSpec extends AkkaSpec(DispatcherDocSpec.config) {
|
|||
}
|
||||
}
|
||||
|
||||
"defining control aware dispatcher" in {
|
||||
new AnyRef {
|
||||
//#control-aware-dispatcher
|
||||
|
||||
// We create a new Actor that just prints out what it processes
|
||||
class Logger extends Actor {
|
||||
val log: LoggingAdapter = Logging(context.system, this)
|
||||
|
||||
self ! 'foo
|
||||
self ! 'bar
|
||||
self ! MyControlMessage
|
||||
self ! PoisonPill
|
||||
|
||||
def receive = {
|
||||
case x => log.info(x.toString)
|
||||
}
|
||||
}
|
||||
val a = system.actorOf(Props(classOf[Logger], this).withDispatcher(
|
||||
"control-aware-dispatcher"))
|
||||
|
||||
/*
|
||||
* Logs:
|
||||
* MyControlMessage
|
||||
* 'foo
|
||||
* 'bar
|
||||
*/
|
||||
//#control-aware-dispatcher
|
||||
|
||||
watch(a)
|
||||
expectMsgPF() { case Terminated(`a`) => () }
|
||||
}
|
||||
}
|
||||
|
||||
"require custom mailbox on dispatcher" in {
|
||||
val myActor = system.actorOf(Props[MyActor].withDispatcher(
|
||||
"custom-dispatcher"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue