Erlang中Actor的基本解释

Basic Explanation of Actors in Erlang

我正在尝试对 Erlang 中的参与者进行非常基本的解释。它应该尽可能简单,但不遗漏理论的关键特征或它的 Erlang 实现。这是我的解释:

The actor model is a mathematical model of concurrent computation that treats actors as the universal primitives of concurrent computation. The actor is a computational entity that, in response to a message it receives, can concurrently (1) send a finite number of messages to other actors, (2) create a finite number of new actors, and (3) designate the behavior to be used for the next message it receives.

In Erlang, each actor is a separate process in the virtual machine, implemented by a function. Processes communicate by sending messages to each other. Every message is explicit, traceable and safe. The messages are received in a mailbox and stored in the order in which they are received. They are stored there until the receiving process takes them out to be read. This is called asynchronous message passing.

大家怎么看?可以吗?我应该添加或更改任何内容吗?谢谢

我认为如果您不将 actor 与 Erlang 进程混淆,您会有所帮助。你从维基百科对 Actor 模型的描述开始,只是为了无缝地开始写关于 Erlang 进程的文章,就像它是一个一样的。 Actor 模型是一种数学模型,可以通过多种不同的方式实现,包括纯 C 或 C++ 低级实现。另一方面,Erlang 进程是轻量级的抢占式语言特性,允许 运行 大量并行进程比使​​用本机系统进程甚至线程更有效。碰巧它们是按照数学模型建模的,但这是基于 specific requirements.

的设计决策

我认为,如果您将 Actor 模型本身作为一个数学模型进行简要讨论,然后再讨论它是如何在 Erlang 中实现的,并指出 Erlang 特有的任何差异和特性,我认为它们会更好地结合在一起。