Akka:当您告诉ActorRef并期望您提出要求时,会发生什么?

编程入门 行业动态 更新时间:2024-10-11 21:22:10
本文介绍了Akka:当您告诉ActorRef并期望您提出要求时,会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下内容:

val future = myActor?消息

在演员中,我的接收消息具有以下内容:

And in my actor my receive message has something like this:

发件人!响应

如果我执行以下操作而忽略了响应,是否有负面影响?

If I do the following and ignore the response, is there any negative impact?

myActor!消息

也许我只是在文档中写错了。就像是一种返回值并且调用者没有将返回值分配给任何东西的方法一样吗?如果我从另一个演员那里打来电话,会不会出现一些奇怪的线程问题或由此导致的内存泄漏?我的单元测试似乎并没有受到影响,但这是人为的。我希望我只是对此问题进行了过度思考,也许我找不到答案,因为这是一个愚蠢的问题,他们的右脑中没人问。

Maybe I'm just missing where it says this in the documentation. Is it like a method that returns a value and the caller doesn't assign the return value to anything? If I make that call from another actor is there going to be some weird threading issue or memory leaks that result from it? My unit tests don't seem to be affected but it's kind of a contrived. I'm hoping I'm just over-thinking the problem and maybe I can't find the answer because it's a stupid question that no one in their right mind asks.

推荐答案

具有请求模式响应的临时轻量演员( PromiseActorRef )。

With ask pattern Response is received by temporary light-weight actor (PromiseActorRef).

如果 myActor!消息范围内应包含隐式 ActorRef 。 响应将发送到此隐式 ActorRef 。除非您明确阅读,否则不会垃圾收集该消息。

In case of myActor ! Message there should be implicit ActorRef in scope. Response will be sent to this implicit ActorRef. This message will not be garbage-collected until you explicitly read it.

如果范围中没有隐式 ActorRef 使用 Actor.noSender ,并且将 Response 转发给系统的deadLetter。

If there is no implicit ActorRef in scope Actor.noSender is used and Response will be forwarded to system's deadLetters.

如果您从另一个演员发出呼叫,此响应将被发送到另一个演员的消息框中。

If you make that call from another actor this Response will be delivered to message box of this another actor.

更多推荐

Akka:当您告诉ActorRef并期望您提出要求时,会发生什么?

本文发布于:2023-11-25 02:32:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627969.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:当您   发生   Akka   ActorRef

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!