gpt4 book ai didi

multithreading - Erlang中Actor的基本解释

转载 作者:行者123 更新时间:2023-12-03 13:04:11 25 4
gpt4 key购买 nike

我正在尝试对 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.

Blockquote

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

最佳答案

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

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

关于multithreading - Erlang中Actor的基本解释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36789810/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com