Advantages of actors over futures

末鹿安然 提交于 2019-12-21 09:27:19

问题


I currently program in Futures, and I'm rather curious about actors. I'd like to hear from an experienced voice:

  • What are the advantages of actors over futures?
  • When should I use one instead of other?

As far as I've read, actors hold state and futures doesn't, is this the only difference? So if I have true immutability I shouldn't care about actors?

Please enlighten me :-)


回答1:


One important difference is that actors typically have internal state, and therefore theoretically, they are not composable; see this and this blog post for having some issues elaborated. However, in practice, they usually provide a sweet spot between the imperative and the purely functional approach. So if possible, it is recommended to stick to programming with only futures, but if the message-passing model fits your problem domain better, feel free to use actors.



来源:https://stackoverflow.com/questions/6682848/advantages-of-actors-over-futures

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!