Actor model

from Wikipedia, the free encyclopedia

The actor model (German actuators model , also actuator model ) is in the computer science a model for concurrent calculations and programs. These are divided into concurrent units, so-called actuators, which communicate exclusively via message exchange . It thus represents a possible form of message passing . It was first described in 1973 by Carl Hewitt , Peter Bishop and Richard Steiger. The Actor Model is used today in the programming languages Erlang , Io , D , Pony and Scala .

functionality

Actuators are concurrent units that do not have a shared memory area but only communicate via messages. The encapsulation of the state of the actuator is similar to the principle of encapsulation in object-oriented programming . Each actor has an inbox, an address and a behavior.

The receipt of a message is known as an event . Received messages are initially saved in the inbox. The actuator processes the messages it contains according to the FIFO principle. The behavior of the actuator describes reactions to messages depending on their structure. Actuators can perform three different reactions:

  • Send messages to yourself or other actors.
  • Generate new actuators.
  • Change your own behavior.

The message exchange takes place asynchronously , i. H. the sender of a message can immediately continue with other actions after sending and does not have to wait for the recipient to accept the message. The Actor Model does not specify how long the delivery of a message can take. It is only defined that every message has to reach the recipient after a finite amount of time. In addition, messages do not necessarily have to arrive in the same order in which they are sent. The latter is still guaranteed in many implementations .

advantages

The fact that actuators only process one message at a time and that no other concurrent process is allowed to influence the internal memory area of ​​an actuator means that programming within the actuator is purely sequential. Assumptions that were made on the basis of the internal state of the actuator at the beginning of the processing of a message remain valid throughout the entire processing of the message. This fundamentally distinguishes the actor model from classic and widespread shared memory concurrency approaches, in which all concurrent threads access a shared memory area and this is partially protected by locking primitives such as semaphores , mutexes and signals.

disadvantage

Since actuators do not have a common memory area, both the messages and the internal memory area of ​​another actuator represent a copy of certain values. Thus, the same information is stored several times in the memory, which leads to an increased memory requirement. In addition, the sending, placing in the mailbox and processing of a message in the actor model is opposed to a (in the best case statically bound) function call in the shared state concurrency. The effort is therefore significantly increased in the actor model.

distribution

The actor model is widely used in functional programming languages. It represents the basic model for concurrency in the programming language Erlang. The model is further spread by languages ​​with mixed paradigms such as Scala. There are also implementations of the actor model for classic imperative programming languages, such as B. Theron as actor library for C ++ .

literature

  • Carl Hewitt, Peter Bishop, Richard Steiger: A Universal Modular Actor Formalism for Artificial Intelligence . In: Proceeding IJCAI'73 Proceedings of the 3rd international joint conference on Artificial intelligence . 1973, p. 235-245 ( online ).
  • Gul Agha: Actors: A Model of Concurrent Computation in Distributed Systems . MIT Press , 1986.
  • Jim Larson: Erlang for Concurrent Programming . In: Queue . tape 6 , no. 5 , 2008, p. 18--23 , doi : 10.1145 / 1454456.1454463 .

Web links

Individual evidence

  1. ^ Carl Hewitt, Peter Bishop, Richard Steiger: A Universal Modular Actor Formalism for Artificial Intelligence . In: Proceeding IJCAI'73 Proceedings of the 3rd international joint conference on Artificial intelligence . 1973, p. 235-245 ( online ).
  2. Pony Lang: Actors · Pony tutorial. In: tutorial.ponylang.org. Retrieved August 22, 2016 .