Actor 模型对共享状态的优势

发布于 2024-07-23 09:34:48 字数 107 浏览 12 评论 0原文

我正在阅读有关 Actor 模型的演示文稿,每个人都声称它优于共享状态并行编程,因为它避免了许多陷阱,例如死锁和竞争条件。 我问自己这个说法的具体内容是什么。 如果避免这些问题,它是如何做到的呢?

I'm reading about the Actor Model for a presentation and everyone claimes that it is superior to shared state parallel programming because it avoids many pitfalls like deadlocks and race conditions. I'm asking myself what the specifics of this claims are.
If it avoids these problems, how does it do it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

厌味 2024-07-30 09:34:48

你的问题确实包含了答案。 参与者的想法是他们不共享状态。 每个都仅根据自己的私有数据进行操作。 由于所有数据都是私有的,理论上您根本不需要任何锁。 如果没有锁,您显然不会遇到死锁等问题。 如果没有要修改的共享数据,竞争条件是不可能的(因为没有两个线程竞争它)。 无论如何,这就是我的乐观看法。 实际上,我怀疑演员模式是否是万能的。 我们肯定会继续看到一些共同的状态向前发展。

Your question really contains the answer. The idea is with actors is that they do not share state. Each operates only on its own, private data. Since all data is private, in theory you won't need any locks at all. Without locks, you're obviously immune to problems like deadlock. Without shared data to modify, race conditions are impossible (since no two threads compete over it). Anyway, that's my rosey take on it. Practically speaking, I doubt the actor pattern is a panacea. We'll certainly continue to see some shared state moving forward.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文