Actor 模型对共享状态的优势
我正在阅读有关 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的问题确实包含了答案。 参与者的想法是他们不共享状态。 每个都仅根据自己的私有数据进行操作。 由于所有数据都是私有的,理论上您根本不需要任何锁。 如果没有锁,您显然不会遇到死锁等问题。 如果没有要修改的共享数据,竞争条件是不可能的(因为没有两个线程竞争它)。 无论如何,这就是我的乐观看法。 实际上,我怀疑演员模式是否是万能的。 我们肯定会继续看到一些共同的状态向前发展。
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.