Does the manufacturer / consumer model match the Actor?

So, recently I read many articles about how difficult it is to work in parallel programming, and how parallel programming with a common state is almost impossible. So, languages ​​like Erlang (I think this is included, if not the question still makes sense) use the Actor model for concurrency and do not have a common state between threads. Now that I was programming parallel systems, I did not find concurrency so complicated, but in general I can put almost any problem into the producer / consumer paradigm and live without a special (if any) general state. Although this is correct? Are message queues between threads actually shared states? Or, the parallel programming producer / consumer model is really a concrete example of the Actor model (this is my real question). Thoughts?

+6
source share
1 answer

Technically, generic messages represent the state of a comprehensive application, but only if the producers and consumers themselves are stateless (otherwise they simply represent the state (s) of the messaging environment / a). The producer / consumer model is not so much an example of the actor model as each individual producer and consumer. Manufacturers (who may also be consumers, either from the same general message queues or from external sources) do what they do and spit out some message that gets into the queue. The queue itself can be considered an actor, albeit passive, because it receives / stores messages and can distribute them (or just wait for them to be received). Consumers are participants in the fact that they receive / receive messages from the general queue and work on the basis of these messages.

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

+4
source

Source: https://habr.com/ru/post/894671/


All Articles