Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala Akka调度员固有性_Scala_Inheritance_Akka_Parent Child_Dispatcher - Fatal编程技术网

Scala Akka调度员固有性

Scala Akka调度员固有性,scala,inheritance,akka,parent-child,dispatcher,Scala,Inheritance,Akka,Parent Child,Dispatcher,我和阿卡一起工作,我们仍然在互相了解 我的场景是:我为主管(家长)参与者选择了一个非默认的调度程序,该参与者的角色是管理(监督)并创建子参与者来完成工作 问题:子角色是否继承父角色的角色 我知道您可以显式地为子参与者指定不同于配置中指定的父参与者的调度程序 akka.actor.deployment { /my-parent-actor { dispatcher = dispatcher-for-parent } "/my-parent-actor/*" { dis

我和阿卡一起工作,我们仍然在互相了解

我的场景是:我为主管(家长)参与者选择了一个非默认的调度程序,该参与者的角色是管理(监督)并创建子参与者来完成工作

问题:子角色是否继承父角色的角色

我知道您可以显式地为子参与者指定不同于配置中指定的父参与者的调度程序

akka.actor.deployment {
  /my-parent-actor {
    dispatcher = dispatcher-for-parent
  }

  "/my-parent-actor/*" {
    dispatcher = dispatcher-for-children
  }
}

我的问题是,如果您指定父参与者调度程序,而没有为子参与者显式指定调度程序,那么父参与者的子参与者是否具有继承性。

据我所见,默认情况下,子参与者不会继承父参与者的主管。我无法在任何地方的文档中明确找到这一点,因此我编写了一段快速代码来验证我最初的假设:

import com.typesafe.config.ConfigFactory
import akka.actor._

object DispatcherTest extends App{

  val conf = ConfigFactory.parseString("""
      {
          my-custom-dispatcher {
            executor = "thread-pool-executor"
            type = PinnedDispatcher         
          }
      }  
  """)

  val system = ActorSystem("test", conf)
  val supervisor = system.actorOf(Props[MySupervisor].withDispatcher("my-custom-dispatcher"))

}

class MySupervisor extends Actor{
  println(s"I am the supervisor, my dispatcher is: ${context.dispatcher}")
  val child = context.actorOf(Props[MyChild])
  def receive = {
    case _ =>      
  }
}

class MyChild extends Actor{
  println(s"I am the child, my dispatcher is: ${context.dispatcher}")
  def receive = {
    case _ =>
  }
}
如果运行此操作,您将看到:

I am the supervisor, my dispatcher is: PinnedDispatcher[my-custom-dispatcher]
I am the child, my dispatcher is: Dispatcher[akka.actor.default-dispatcher]

谢谢你。回答得好!在这个与阿克卡相互了解的阶段,将我所看到的与具有相同结果的其他人联系起来,这真的很好。再次感谢!!