如何在Scala Actor模型中重载bang(!)运算符? [英] How to overload bang(!) operator in Scala Actor model?

查看:100
本文介绍了如何在Scala Actor模型中重载bang(!)运算符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Scala中的Actor模型实现中,我们可以覆盖bang(!)运算符。
我们可以通过重载此运算符来修改消息传递的操作吗?

In an Actor model implementation in Scala, can we override the bang(!) operator. Can we modify the operation of message passing by overloading this operator?

示例场景:
当任何参与者调用时,我都需要包括信息记录通过传递消息来另一个
演员。因此,通过重载message pass(!)运算符,我可以

跟踪不同参与者之间的消息传递,并避免为每个参与者消息传递调用包括logger
语句吗?

Example scenario: I need to include logging of information when any actor invokes another actor by passing a message. So by overloading the message pass(!) operator, Can I
track the message passing between different actors and avoid including logger statement for every actor message passing call?

推荐答案


在Scala中的Actor模型实现中,我们可以覆盖bang(!)运算符。

In an Actor model implementation in Scala, can we override the bang(!) operator.

可以,但是我强烈建议您反对。

You can, but I would strongly recommend against it.


示例场景:当任何演员通过传递消息来调用另一个演员时,我都需要记录信息。

Example scenario: I need to include logging of information when any actor invokes another actor by passing a message.




  1. 这不适用于任何不扩展您类型的角色:Akka系统角色,库创建的角色等。

  1. This won't work with any actors which don't extend your type: Akka system actors, actors created by libraries, etc.

Akka已经可以做到,只需设置 akka.debug.receive = on

这篇关于如何在Scala Actor模型中重载bang(!)运算符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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