Akka:当您告诉ActorRef并期望您提出要求时,会发生什么? [英] Akka: What happens when you tell an ActorRef and it expects you to ask?

查看:71
本文介绍了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并期望您提出要求时,会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆