I came across this code and wonder what CallingThreadDispatcher does. I can comment out
val dispatcherId = CallingThreadDispatcher.Id
val props = Props[Greeter].withDispatcher(dispatcherId)
and this test will still work
class GreeterTest extends TestKit(testSystem)
with WordSpecLike
with MustMatchers
with StopSystemAfterAll {
"The Greeter" must {
"say Hello World! when a Greeting(\"World\") is sent to it" in {
val dispatcherId = CallingThreadDispatcher.Id
val props = Props[Greeter].withDispatcher(dispatcherId)
val greeter = system.actorOf(props)
EventFilter.info(message = "Hello World!", occurrences = 1).intercept {
greeter ! Greeting("World")
}
}
}
}
object GreeterTest {
val testSystem = {
val config = ConfigFactory.parseString("""akka.loggers = [akka.testkit.TestEventListener]""")
ActorSystem("testSystem", config)
}
}
So what does CallingThreadDispatcher do? and why do we need it?
Aucun commentaire:
Enregistrer un commentaire