參與者模式

维基百科,自由的百科全书
跳转至: 导航搜索

計算機科學中,參與者模式英语Actor model)是一種並行運算上的模型。「參與者」是一種程式上的抽象概念,被視為並行運算的基本單元:當一個參與者接收到一則訊息,它可以做出一些決策、建立更多的參與者、傳送更多的訊息、決定要如何回答接下來的訊息。參與者模式在1973年於Carl HewittPeter BishopRichard Steiger的論文中提出[1]

基本概念[编辑]

参与者模型推崇的哲学是“一切皆是参与者”,这与面向对象编程的“一切皆是对象”类似,但是面向对象编程通常是顺序执行的,而参与者模型是并行执行的。

参与者是一个运算实体,回应接受到的消息,同时并行的:

  • 发送有限数量的消息给其他参与者;
  • 创建有限数量的新参与者;
  • 指定接受到下一个消息时的行为。

以上操作不含有顺序执行的假设,因此可以并行进行。

发送者与已经发送的消息解耦,是参与者模型的根本优势。这允许进行异步通信,同时满足消息传递的控制结构。[2]

消息接收者是通过地址区分的,有时也被称作“邮件地址”。因此参与者只能和它拥有地址的参与者通信。它可以通过接受到的信息获取地址,或者获取它创建的参与者的地址。

参与者模型的特征是,参与者内部或之间进行并行计算,参与者可以动态创建,参与者地址包含在消息中,交互只有通过直接的异步消息通信,不限制消息到达的顺序。

使用参与者模式编程[编辑]

一些编程语言使用了参与者模型或变种。这些语言包括:

早期参与者模式编程语言[编辑]

后期参与者模式编程语言[编辑]

参与者模式库及框架[编辑]

参与者模式库及框架,允许用户在没有那只参与者模式的语言中进行编程。这些框架包括

名称 状态 最后发布 软件许可证 语言
Actor 1活跃 2013-05-30 MIT Java
Actor Framework 1活跃 2013-11-13 Apache 2.0 .NET
Akka (toolkit) 1活跃 2014-03-26 Apache 2.0 Java and Scala
Akka.NET 1活跃 2014-02-01 Apache 2.0 .NET
Remact.Net 1活跃 2014-03-23 MIT .NET
Ateji PX 1活跃  ?  ? Java
F# MailboxProcessor 1活跃 same as F# (built-in core library) Apache License F#
Korus 1活跃 2010-02-01 GPL 3 Java
Kilim[15] 1活跃 2011-10-13[16] MIT Java
ActorFoundry (based on Kilim) 活跃? 2008-12-28  ? Java
ActorKit 1活跃 2011-09-14[17] BSD Objective-C
Cloud Haskell 1活跃 2012-11-07[18] BSD Haskell
CloudI 1活跃 2014-02-02[19] BSD Erlang, C/C++, Java, Python, Ruby
NAct 0活跃 2012-02-28 LGPL 3.0 .NET
Retlang 0活跃 2011-05-18[20] New BSD .NET
JActor 1活跃 2013-01-22 LGPL Java
Jetlang 1活跃 2012-02-14 [21] New BSD Java
Haskell-Actor 活跃? 2008 New BSD Haskell
GPars 1活跃 2012-12-19 Apache 2.0 Groovy
PARLEY 活跃? 2007-22-07 GPL 2.1 Python
Pulsar 1活跃 2013-06-30 New BSD Python
Pulsar 1活跃 2013-07-19 [22] LGPL/Eclipse Clojure
Pykka 1活跃 2013-07-15 [23] Apache 2.0 Python
Termite Scheme 活跃? 2009 LGPL Scheme (Gambit implementation)
Theron 1活跃 2012-08-20[24] MIT[25] C++
Quasar 1活跃 2013-07-19 [26] LGPL/Eclipse Java
Libactor 活跃? 2009 GPL 2.0 C
Actor-CPP 1活跃 2012-03-10[27] GPL 2.0 C++
S4 1活跃 2011-11-28[28] Apache 2.0 Java
C++ Actor Framework (CAF) 1活跃 2014-07-23[29] Boost Software License 1.0 and BSD 3-Clause C++11
Celluloid 1活跃 2012-07-17[30] MIT Ruby
LabVIEW Actor Framework 1活跃 2012-03-01[31]  ? LabVIEW
QP frameworks for real-time embedded systems 1活跃 2012-09-07[32] GPL 2.0 and commercial (dual licensing) C and C++
libprocess 1活跃 2012-07-13 Apache 2.0 C++
SObjectizer 1活跃 2014-07-01 New BSD C++

注意这里没有列出全部框架和库。

參考資料[编辑]

  1. ^ Carl Hewitt; Peter Bishop and Richard Steiger. A Universal Modular Actor Formalism for Artificial Intelligence. IJCAI. 1973. 
  2. ^ Carl Hewitt. Viewing Control Structures as Patterns of Passing Messages Journal of Artificial Intelligence. June 1977.
  3. ^ Henry Lieberman. A Preview of Act 1. MIT AI memo 625. June 1981. 
  4. ^ Henry Lieberman. Thinking About Lots of Things at Once without Getting Confused: Parallelism in Act 1. MIT AI memo 626. June 1981. 
  5. ^ Jean-Pierre Briot. Acttalk: A framework for object-oriented concurrent programming-design and experience 2nd France-Japan workshop. 1999.
  6. ^ Ken Kahn. A Computational Theory of Animation MIT EECS Doctoral Dissertation. August 1979.
  7. ^ 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.
  8. ^ Darrell Woelk. Developing InfoSleuth Agents Using Rosette: An Actor Based Language Proceedings of the CIKM '95 Workshop on Intelligent Information Agents. 1995.
  9. ^ 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
  10. ^ Darryl K. Taft. Microsoft Cooking Up New Parallel Programming Language. Eweek.com. 2009-04-17 [2012-12-02]. 
  11. ^ Humus. Dalnefre.com. [2012-12-02]. 
  12. ^ Carlos Varela and Gul Agha. Programming Dynamically Reconfigurable Open Systems with SALSA. ACM SIGPLAN Notices. OOPSLA'2001 Intriguing Technology Track Proceedings. 2001, 36. 
  13. ^ Philipp Haller and Martin Odersky. Event-Based Programming without Inversion of Control (PDF). Proc. JMLC 2006. September 2006. 
  14. ^ Philipp Haller and Martin Odersky. Actors that Unify Threads and Events (PDF). Technical report LAMP 2007. January 2007. 
  15. ^ Srinivasan, Sriram; Alan Mycroft. Kilim: Isolation-Typed Actors for Java. European Conference on Object Oriented Programming ECOOP 2008 (PDF). Cyprus. 2008 [2008-07-24]. 
  16. ^ Commit History · kilim/kilim · GitHub. Github.com. [2012-12-02]. 
  17. ^ Commit History · stevedekorte/ActorKit · GitHub. Github.com. [2012-12-02]. 
  18. ^ Commit History · haskell-distributed/distributed-process · GitHub. Github.com. [2012-12-02]. 
  19. ^ Commit History · CloudI/CloudI · GitHub. Github.com. [2014-03-19]. 
  20. ^ Changes - retlang - Message based concurrency in .NET - Google Project Hosting. Code.google.com. [2012-12-02]. 
  21. ^ 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]. 
  22. ^ Pulsar documentation. 
  23. ^ Changes — Pykka 1.2.0 documentation. pykka.org. [2014-03-30]. 
  24. ^ Theron. Theron-library.com. [2012-12-02]. 
  25. ^ Theron. Theron-library.com. [2012-12-02]. 
  26. ^ Pulsar GitHub. 
  27. ^ Changes - actor-cpp - An implementation of the actor model for C++ - Google Project Hosting. Code.google.com. [2012-12-02]. 
  28. ^ Commit History · s4/s4 · GitHub. Github.com. [2012-12-02]. 
  29. ^ Tags · actor-framework/actor-framework · GitHub. Github.com. [2014-07-23]. 
  30. ^ celluloid | RubyGems.org | your community gem host. RubyGems.org. [2012-12-02]. 
  31. ^ Community: Actor Framework, LV 2011 revision (version 3.0.7). Decibel.ni.com. [2012-12-02]. 
  32. ^ QP Active Object Frameworks - Browse Files at. Sourceforge.net. [2012-12-02].