gpt4 book ai didi

scala - Akka actorSelection vs actorOf Difference

转载 作者:行者123 更新时间:2023-12-04 22:59:17 27 4
gpt4 key购买 nike

这两者有区别吗?当我做:

context.actorSelection(actorNameString)

我得到一个 ActorSelection 引用,我可以使用 resolveOne 来解析它,然后我得到一个 Future[ActorRef]。但是有了actorOf,我会立即得到一个ActorRef。除此之外还有其他重要的区别吗?

我希望将 ActorRef 包装在 Future 中的用例可能是什么?

最佳答案

Actor 用于创建新 Actor 通过提供他们的 Prop 对象。

Actor 选拔指向actor树中路径的“指针” .通过使用resolveOne,您将获得该路径下现有actor的actorRef - 但是actorRef需要时间来解析,因此是Future。

这里有更详细的解释:
http://doc.akka.io/docs/akka/snapshot/general/addressing.html

An actor reference designates a single actor and the life-cycle of the reference matches that actor’s life-cycle; an actor path represents a name which may or may not be inhabited by an actor and the path itself does not have a life-cycle, it never becomes invalid. You can create an actor path without creating an actor, but you cannot create an actor reference without creating corresponding actor.

关于scala - Akka actorSelection vs actorOf Difference,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30883689/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com