erlang中的ref是什么? [英] What is ref in Erlang?

查看:293
本文介绍了erlang中的ref是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过此链接

要标识一个进程,我们将使用一个Pid。

To identify a process,we would be using a Pid. When should a ref be used?

我在发送/接收消息时经常看到此消息,但无法解释它在消息交互中起什么作用。

I see this often while message sending/receiving but unable to interpret what role it plays in message interaction.

推荐答案

引用文档


引用是在Erlang运行时系统中唯一的术语,通过调用make_ref / 0创建。

A reference is a term which is unique in an Erlang runtime system, created by calling make_ref/0.

这意味着这是特殊的数据类型,它不是整数,不是列表,也不是二进制。尤其是随着独特的繁荣。它主要用于识别代码中的某些位置。 make_ref(),无论在哪里调用,都将返回新值(在它的尺寸。就像弗雷德在书中所描述的那样,它非常适合标记消息,并识别我们收到的消息是否是对我们刚发送的消息的回应。

This means that this is special data type, it's not an integer, not a list, and not a binary. Especially with unique prosperity. It's designed mostly to recognize some places in code. make_ref(), no matter where it is called, will return new value (in boundaries of it's size of course). And just like Fred describes in it's book, it is great for tagging messages, and recognizing if message we receive is in response to one we just send.

这篇关于erlang中的ref是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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