erlang - 什么是 BEAM 中的同步调用技巧/参考技巧
问题描述
作为我们阅读小组的一部分,我们最近正在阅读BEAM 书。第 7 章提到了 Erlang 中的 ref 技巧/同步调用技巧。
不幸的是,这本书是不完整的,经过讨论,我们无法弄清楚参考技巧是什么。
解决方案
在执行 时receive
,BEAM VM 会扫描邮箱以找到第一个合适的(匹配的)消息,如果找不到,则阻止该进程。
“诀窍”是,由于在创建新引用之前不可能在邮箱中存在新引用,因此无需在 时扫描整个邮箱receive {Reference, Term}
,只需从Reference
创建的点开始。
这就是下面这句话的意思:
The compiler recognizes code that uses a newly created reference (ref) in a receive (see [ref_trick_code]), and emits code to avoid the long inbox scan since the new ref can not already be in the inbox.
推荐阅读
- java - 泛型情况下的 Spring 事件路由
- c - 在 if 语句中使用浮点变量时出现意外输出
- python - Python regex 编译和搜索带有数字和单词的字符串
- angular - 使用 ng2-charts 正确配置 chartjs-plugin-annotation 的位置?
- css - 传单标记显示 css 框架和使用窗格的问题
- postgresql - 错误:FOR UPDATE 不能应用于外连接的可空端
- reactjs - ReactNative useEffect Parent to Child 数据刷新
- javascript - 如何检查一个人是否对自己进行了 ping 操作 discord.js
- php - Paypal 订阅设置 IPN 侦听器 url
- java - Android Oreo 及更高版本上的隐式广播接收器