Actor model
下面是解决Actor model非常好的文章:
1、codemag Writing Concurrent Programs Using F# Mailbox Processors
2、brianstorti The actor model in 10 minutes
3、TODO rocketeer Concurrency in Erlang & Scala: The Actor Model
使用了Actor model的
Erlang programming language and actor model
关于 Erlang programming language and actor model,在下面文章中进行描述:
1、codemag Writing Concurrent Programs Using F# Mailbox Processors
2、brianstorti The actor model in 10 minutes
3、TODO rocketeer Concurrency in Erlang & Scala: The Actor Model
Python celery
Instantiation¶
A task is not instantiated for every request, but is registered in the task registry as a global instance.
This means that the
__init__
constructor will only be called once per process, and that the task class is semantically closer to an Actor.
wikipedia Actor model
NOTE: 参与者模型
The actor model in computer science is a mathematical model of concurrent computation that treats "actors" as the universal primitives of concurrent computation(其将“actors”视为并发计算的通用原语). In response to a message that it receives, an actor can:
1、make local decisions
2、create more actors
3、send more messages
4、determine how to respond to the next message received.
Actors may modify their own private state, but can only affect each other through messages (avoiding the need for any locks).
The actor model originated in 1973.[1] It has been used both as a framework for a theoretical understanding(理论上理解) of computation and as the theoretical basis for several practical implementations(实际实现) of concurrent systems. The relationship of the model to other work is discussed in Actor model and process calculi.
Fundamental concepts
The actor model adopts the philosophy(哲学) that everything is an actor. This is similar to the everything is an object philosophy used by some object-oriented programming languages.
NOTE:
1、让我想到了Unix "everything is a file philosophy"
An actor is a computational entity that, in response to a message it receives, can concurrently:
- send a finite number of messages to other actors;
- create a finite number of new actors;
- designate the behavior to be used for the next message it receives.
There is no assumed sequence to the above actions and they could be carried out in parallel.
Decoupling the sender from communications sent was a fundamental advance of the Actor model enabling asynchronous communication and control structures as patterns of passing messages.[8]
Recipients(接收) of messages are identified by address, sometimes called "mailing address". Thus an actor can only communicate with actors whose addresses it has. It can obtain those from a message it receives, or if the address is for an actor it has itself created.
The actor model is characterized by inherent(固有的,内在的,天生的) concurrency of computation within(内部) and among(之间) actors, dynamic creation of actors, inclusion of actor addresses in messages, and interaction only through direct asynchronous message passing with no restriction on message arrival order.
actor模型的特征在于actor内部和之间的计算的内在并发性,actor的动态创建,在消息中包含actor地址,以及仅通过直接异步消息传递的交互,而不限制消息到达顺序。