角色模型
在電腦科學中,角色模型(英语:Actor model)是一種並行運算上的模型。「角色」是一種程式上的抽象概念,被視為並行運算的基本單元:當一個角色接收到一則訊息,它可以做出一些決策、建立更多的角色、傳送更多的訊息、決定要如何回答接下來的訊息。角色模型在1973年於Carl Hewitt、Peter Bishop及Richard Steiger的論文中提出[1]。
目录
1 基本概念
2 使用角色模型编程
2.1 早期角色模型编程语言
2.2 后期角色模型编程语言
2.3 角色模型库及框架
3 參考資料
基本概念
角色模型推崇的哲学是“一切皆是角色”,这与面向对象编程的“一切皆是对象”类似,但是面向对象编程通常是顺序执行的,而角色模型是并行执行的。
角色是一个运算实体,回应接受到的消息,同时并行的:
- 发送有限数量的消息给其他角色;
- 创建有限数量的新角色;
- 指定接受到下一个消息时的行为。
以上操作不含有顺序执行的假设,因此可以并行进行。
发送者与已经发送的消息解耦,是角色模型的根本优势。这允许进行异步通信,同时满足消息传递的控制结构。[2]
消息接收者是通过地址区分的,有时也被称作“邮件地址”。因此角色只能和它拥有地址的角色通信。它可以通过接受到的信息获取地址,或者获取它创建的角色的地址。
角色模型的特征是,角色内部或之间进行并行计算,角色可以动态创建,角色地址包含在消息中,交互只有通过直接的异步消息通信,不限制消息到达的顺序。
使用角色模型编程
一些编程语言使用了角色模型或变种。这些语言包括:
早期角色模型编程语言
- Act 1, 2 and 3[3][4]
- Acttalk[5]
- Ani[6]
- Cantor[7]
- Rosette[8]
后期角色模型编程语言
|
|
角色模型库及框架
角色模型库及框架,允许用户在没有内置角色模型的语言中进行编程。这些框架包括
| 名称 | 状态 | 最后发布 | 软件许可证 | 语言 |
|---|---|---|---|---|
Aojet | 活跃 | 2016-10-17 | MIT | Swift |
Actor | 活跃 | 2013-05-30 | MIT | Java |
Actor Framework | 活跃 | 2013-11-13 | Apache 2.0 | .NET |
Akka (toolkit) | 活跃 | 2014-03-26 | Apache 2.0 | Java and Scala |
Akka.NET | 活跃 | 2014-02-01 | Apache 2.0 | .NET |
Remact.Net | 活跃 | 2014-03-23 | MIT | .NET |
Ateji PX | 活跃 | ? | ? | Java |
F# MailboxProcessor | 活跃 | same as F# (built-in core library) | Apache License | F# |
Korus | 活跃 | 2010-02-01 | GPL 3 | Java |
Kilim[15] | 活跃 | 2011-10-13[16] | MIT | Java |
ActorFoundry (based on Kilim) | 活跃? | 2008-12-28 | ? | Java |
ActorKit | 活跃 | 2011-09-14[17] | BSD | Objective-C |
Cloud Haskell | 活跃 | 2012-11-07[18] | BSD | Haskell |
CloudI | 活跃 | 2014-02-02[19] | BSD | Erlang, C/C++, Java, Python, Ruby |
NAct | 活跃 | 2012-02-28 | LGPL 3.0 | .NET |
Retlang | 活跃 | 2011-05-18[20] | New BSD | .NET |
JActor | 活跃 | 2013-01-22 | LGPL | Java |
Jetlang | 活跃 | 2012-02-14 [21] | New BSD | Java |
Haskell-Actor | 活跃? | 2008 | New BSD | Haskell |
GPars | 活跃 | 2012-12-19 | Apache 2.0 | Groovy |
PARLEY | 活跃? | 2007-22-07 | GPL 2.1 | Python |
Pulsar | 活跃 | 2013-06-30 | New BSD | Python |
Pulsar | 活跃 | 2013-07-19 [22] | LGPL/Eclipse | Clojure |
Pykka | 活跃 | 2013-07-15 [23] | Apache 2.0 | Python |
Termite Scheme | 活跃? | 2009 | LGPL | Scheme (Gambit implementation) |
Theron | 活跃 | 2012-08-20[24] | MIT[25] | C++ |
Quasar | 活跃 | 2013-07-19 [26] | LGPL/Eclipse | Java |
Libactor | 活跃? | 2009 | GPL 2.0 | C |
Actor-CPP | 活跃 | 2012-03-10[27] | GPL 2.0 | C++ |
S4 | 活跃 | 2011-11-28[28] | Apache 2.0 | Java |
C++ Actor Framework (CAF) | 活跃 | 2014-07-23[29] | Boost Software License 1.0 and BSD 3-Clause | C++11 |
Celluloid | 活跃 | 2012-07-17[30] | MIT | Ruby |
LabVIEW Actor Framework | 活跃 | 2012-03-01[31] | ? | LabVIEW |
QP frameworks for real-time embedded systems | 活跃 | 2012-09-07[32] | GPL 2.0 and commercial (dual licensing) | C and C++ |
libprocess | 活跃 | 2012-07-13 | Apache 2.0 | C++ |
SObjectizer | 活跃 | 2014-07-01 | New BSD | C++ |
注意这里没有列出全部框架和库。
參考資料
^ Carl Hewitt; Peter Bishop and Richard Steiger. A Universal Modular Actor Formalism for Artificial Intelligence (PDF). IJCAI. 1973. (原始内容 (PDF)存档于2009-12-29). 引文使用过时参数coauthors (帮助)
^ Carl Hewitt. Viewing Control Structures as Patterns of Passing Messages Journal of Artificial Intelligence. June 1977.
^ Henry Lieberman. A Preview of Act 1 (PDF). MIT AI memo 625. June 1981. [永久失效連結]
^ Henry Lieberman. Thinking About Lots of Things at Once without Getting Confused: Parallelism in Act 1 (PDF). MIT AI memo 626. June 1981. [永久失效連結]
^ Jean-Pierre Briot. Acttalk: A framework for object-oriented concurrent programming-design and experience 2nd France-Japan workshop. 1999.
^ Ken Kahn. A Computational Theory of Animation MIT EECS Doctoral Dissertation. August 1979.
^ William Athas and Nanette Boden Cantor: An Actor Programming System for Scientific Computing in Proceedings of the NSF Workshop on Object-Based Concurrent Programming. 1988. Special Issue of SIGPLAN Notices.
^ Darrell Woelk. Developing InfoSleuth Agents Using Rosette: An Actor Based Language Proceedings of the CIKM '95 Workshop on Intelligent Information Agents. 1995.
^ Dedecker J., Van Cutsem T., Mostinckx S., D'Hondt T., De Meuter W. Ambient-oriented Programming in AmbientTalk. In “Proceedings of the 20th European Conference on Object-Oriented Programming (ECOOP), Dave Thomas (Ed.), Lecture Notes in Computer Science Vol. 4067, pp. 230-254, Springer-Verlag.”, 2006
^ Darryl K. Taft. Microsoft Cooking Up New Parallel Programming Language. Eweek.com. 2009-04-17 [2012-12-02].
^ Humus. Dalnefre.com. [2012-12-02].
^ Carlos Varela and Gul Agha. Programming Dynamically Reconfigurable Open Systems with SALSA. ACM SIGPLAN Notices. OOPSLA'2001 Intriguing Technology Track Proceedings. 2001, 36.
^ Philipp Haller and Martin Odersky. Event-Based Programming without Inversion of Control (PDF). Proc. JMLC 2006. September 2006.
^ Philipp Haller and Martin Odersky. Actors that Unify Threads and Events (PDF). Technical report LAMP 2007. January 2007.
^ Srinivasan, Sriram; Alan Mycroft. Kilim: Isolation-Typed Actors for Java (PDF). European Conference on Object Oriented Programming ECOOP 2008. Cyprus. 2008 [2008-07-24].
^ Commit History · kilim/kilim · GitHub. Github.com. [2012-12-02].
^ Commit History · stevedekorte/ActorKit · GitHub. Github.com. [2012-12-02].
^ Commit History · haskell-distributed/distributed-process · GitHub. Github.com. [2012-12-02].
^ Commit History · CloudI/CloudI · GitHub. Github.com. [2014-03-19].
^ Changes - retlang - Message based concurrency in .NET - Google Project Hosting. Code.google.com. [2012-12-02].
^ jetlang-0.2.9-bin.zip - jetlang - jetlang-0.2.9-bin.zip - Message based concurrency for Java - Google Project Hosting. Code.google.com. 2012-02-14 [2012-12-02].
^ Pulsar documentation. (原始内容存档于2013-07-26).
^ Changes — Pykka 1.2.0 documentation. pykka.org. [2014-03-30].
^ Theron. Theron-library.com. [2012-12-02].
^ Theron. Theron-library.com. [2012-12-02].
^ Pulsar GitHub.
^ Changes - actor-cpp - An implementation of the actor model for C++ - Google Project Hosting. Code.google.com. [2012-12-02].
^ Commit History · s4/s4 · GitHub. Github.com. [2012-12-02].
^ Tags · actor-framework/actor-framework · GitHub. Github.com. [2014-07-23].
^ celluloid | RubyGems.org | your community gem host. RubyGems.org. [2012-12-02].
^ Community: Actor Framework, LV 2011 revision (version 3.0.7). Decibel.ni.com. [2012-12-02].
^ QP Active Object Frameworks - Browse Files at. Sourceforge.net. [2012-12-02].