Scala 2.8Beta1 演员

发布于 2024-08-22 21:15:22 字数 501 浏览 2 评论 0原文

呼唤!!即使在调用者收到回复后(即:未来已准备好),从一个参与者到另一个工作参与者的方法似乎仍保持通道打开。

例如,使用 !!从一个 actor 向另一个工作 actor 发送 11 条不同的消息将导致原始调用者的邮箱中显示类似于下面的 11 条消息,每条消息都有不同的 Channel@xxxx 值。

!(scala.actors.Channel@11b456f,Exit(com.test.app.actor.QueryActor@4f7bc2,'normal))

这些消息是否正在等待工作人员的回复,因为原始调用者正在自行发送退出消息调用 exit(),或者它们是在另一端生成的,并且由于某种原因具有上面显示的打印表单?此时,worker actor 已经退出,所以原来的调用者 !!绝对不会收到任何回复。

这种行为是不可取的,因为原始调用参与者的邮箱中充满了这些退出消息(每次使用 !! 时创建的每个通道都有一个)。

怎么才能阻止这种情况呢?原始呼叫者是否自动“链接”到每个上创建的回复通道!称呼?

Calling the !! method from one actor to another worker actor appears to keep the channel open even after the reply was received by the caller (ie: future is ready).

For example, using !! to send 11 different messages from one actor to another worker actor will result in 11 messages similar to the below being shown in the mailbox of the original caller, each with a different Channel@xxxx value.

!(scala.actors.Channel@11b456f,Exit(com.test.app.actor.QueryActor@4f7bc2,'normal))

Are these messages awaiting replies from the worker, as the original caller is sending an Exit message out upon it's own call to exit(), or are they generated on the other end, and for some reason have the print form shown above? By this point, the worker actor has already exited, so the original caller of !! will definitely never receive any replies.

This behavior is undesirable, as the original calling actor's mailbox fills with these exit messages (one for each channel created for each time !! was used).

How can this be stopped? Is the original caller automatically "linking" to the reply channels created on each !! call?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故乡的云 2024-08-29 21:15:22

这些 Exit 消息发送给原始调用者的原因是调用者将其用于接收未来结果的临时通道链接到被调用者。特别是,如果通道收到退出信号,则会在该通道上发送退出消息,这会生成一条类似于您所描述的要发送给实际调用者的消息(您可以将通道视为消息上的标签)。这样做是为了如果被调用者在服务未来消息发送之前终止(在访问未来时抛出异常),则允许在调用者内部(重新)抛出异常。

当前实现的问题是,即使未来已经解决,调用者也会收到退出消息。这显然是一个应该在 Scala Trac 上提交的错误。一个可能的解决方法是仅在未来尚未解决时才发送退出消息。在这种情况下,每当第一次使用 apply 或 isSet 访问 future 时,退出消息都会被删除。

The reason why these Exit messages are sent to the original caller is that the caller links its temporary channel, which is used to receive the future result, to the callee. In particular, if the channel receives an exit signal, an Exit message is sent on that channel, which results in a message similar to what you describe to be sent to the actual caller (you can think of channels as tags on messages). This is done to allow (re-)throwing an exception inside the caller if the callee terminates before serving the future message send (the exception is thrown upon accessing the future).

The problem with the current implementation is that the caller receives an Exit message even if the future was already resolved. This is clearly a bug that should be filed on the Scala Trac. A possible fix is to only send an Exit message if the future has not been resolved, yet. In this case the Exit message will be removed whenever the future is accessed for the first time using apply or isSet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文