C++多线程开发之actor model.
最近想把写过的一个多线程程序整理一下,这个程序主要特点是有一系列的互相之间有依赖关系的task。于是在网上找相关类库
1,一类是简单的线程池了,这也是原本俺的做法。之前使用的是手工调度,代码实现的很蛋疼。
外面的lib有poco https://pocoproject.org/slides/130-Threads.pdf
3,微软的并行库
1)MS PPL (Parallel Patterns Library)之类的类库,感觉这里一类本质上和1没有大的分别
2)MS tpl (Task Parallel Library) ,是Dataflow,可以显式指明task之间的依赖关系
https://msdn.microsoft.com/en-us/library/hh228603(v=vs.110).aspx
http://blog.i3arnon.com/2016/05/23/tpl-dataflow/
3) MS Asynchronous Agents Library ,没研究,抽空看看
Update 20161220: 貌似大家对这个actor model不满意,他实现得不够完整,并且很久没有更新。 http://www.cnblogs.com/cutepig/p/6206114.html
https://msdn.microsoft.com/en-us/library/dd492627.aspx
https://msdn.microsoft.com/en-us/library/ff601928.aspx
4) MS Concurrency Runtime,没看过,有时间研究下
From stackoverflow, The concurrency runtime is a cooperative scheduling infrastructure也就是说需要task互相协作,如果某个task是io密集的,就不适合?
https://msdn.microsoft.com/en-us/library/ff601929.aspx
https://msdn.microsoft.com/en-us/library/dd504870.aspx
5) AMP https://msdn.microsoft.com/en-us/library/hh265137.aspx
6) MS CCR (Concurrency and Coordination Runtime)
https://msdn.microsoft.com/en-us/library/bb648752.aspx
more
https://msdn.microsoft.com/zh-cn/library/ff963546.aspx
3, 有人说过asyn, future之类,但这一类其实都没有优化task调度
6, actor model
貌似这是普遍的公认的并行处理方法,其好处是task互相隔离,通过发消息彼此通信实现同步
caf: https://www.actor-framework.org/ c++11的写法比较爽
caf读书笔记 http://www.cnblogs.com/zhejiangxiaomai, http://blog.csdn.net/xzwdev/article/details/41700001, http://wenku.baidu.com/view/7e2b6be16529647d2728528e.html, https://arxiv.org/pdf/1505.07368.pdf,https://pdfs.semanticscholar.org/9bc2/003f58a240143bcfdb1f58183e8a172b7d05.pdf,https://www.meetup.com/ACCU-Bay-Area/events/233766624/
Theron 写法有点蛋疼,但其实可以用c++11包一层的
SObjectizer
skynet https://github.com/cloudwu/skynet/wiki
https://github.com/i11cn/simple-cpp-actor
7,task dependency based c++ library
这一类稳定的类库比较少,很多都是用来写paper
其实可以在actor model包装一层函数实现这一类的用法
比如 SuperGlue: http://tillenius.github.io/superglue/ It's a C++98 header-only library for tasks with dependencies between them.
https://github.com/RichieSams/FiberTaskingLib
http://www.des.udc.es/~basilio/papers/Gonzalez13-DepSpawn.pdf
papers
http://www.ademiller.com/tech/reports/paraplop_2010_the_task_graph_pattern.pdf
8,intel 的类库
1)tbb
2)cnc (Concurrent Collections for C++)
https://icnc.github.io/api/tutorial.html
据说很不同,有空研究下
3)intel tbb-flow-graph
https://www.threadingbuildingblocks.org/tutorial-intel-tbb-flow-graph
9,hpx http://stellar.cct.lsu.edu/files/hpx-0.9.99/html/hpx/tutorial/examples/accumulator.html
没研究过
10,Spark
没研究过
11,相关资料
Stream processing https://en.wikipedia.org/wiki/Stream_processing
Dataflow programming
Actor model
Data-driven programming
Digital signal processing
Event-driven programming
Flow-based programming https://en.wikipedia.org/wiki/Flow-based_programming
Functional reactive programming
Glossary of reconfigurable computing
High-performance reconfigurable computing
Incremental computing
Parallel programming model
Partitioned global address space
Signal programming
Stream processing
Pipeline (Unix)
Yahoo Pipes