开发者

Does Producer/Consumer model equal Actor?

So lately I've been reading a lot of article about how concurrent programming is hard, and how concurrent programming with shared state is near impossible. So languages like Erlang (I think this is on, if not the question still makes sense) use the Actor model for concurrency and have no shared state between threads. Now in my time programming concurrent systems I've not found concurrency to be that hard - but in general I can fit almost any problem into the producer/consumer paradigm and live without much (if any) shared state. Although is that corre开发者_如何学JAVAct? Are the message queues between threads actually shared state? Or is the producer/consumer model of concurrent programming really a concrete example of the Actor model (that's my real question). Thoughts?


Technically the shared messages represent the state of the overarching application, but only if the producers and consumers are themselves stateless (otherwise they simply represent the state(s) of the message-sharing medium/a). The producer/consumer model isn't so much an example of the actor model as each individual producer and consumer is. The producers (who may be consumers as well, either from the same shared message queues or from external sources) do what they do and spit out some message that gets queued up. The queue itself may be considered an actor, although a passive one, in that it recieves/holds messages, and may distribute them (or just wait for them to be taken). The consumers are actors in that they take/recieve messages from the shared queue, and do work based on those messages.

So basically my answer is that the producer/consumer model is not an example of the Actor model, but rather an example of a collection of Actors working in a shared environment.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜