Actors implementation built on C++0x thread standard
I'm a little disappointed to find that the C++0x
concurrency standard doesn't seem to 开发者_StackOverflowhave any native support for a message-passing Actors model.
Is there any support for this that I am missing? Maybe something in futures/promises? Is there any strong community effort to build a de facto standard implementation on top of the C++0x
threading standards?
Currently I have found two possible solutions: Theron and libcppa. Both are based on Boost threads and so should be easily portable to C++11 threads. Both are developed by individuals.
Mostly because I found it first, and because it has very nice documentation, I went ahead and tried Theron
and it works quite nicely. My test application was not especially Actors appropriate, and only needed as many Actors as hardware cores, but I got about 4.5x speedup with 6 threads on 6 cores and 6x speedup with 12 threads on 6 cores with hyperthreading. Pretty good and it only took a few hours to get working and I didn't have to touch threads or mutexes at all. I also implemented a version that spawned thousands of actors and that worked fine too although it was significantly slower for this implementation.
The only downsides I've found are that it doesn't work for interprocess/intermachine/distributed applications, and it's currently a little Windows-centric (although I got it working on a Mac and Linux machine without too much trouble).
I also tried libcppa and got a toy example working without too much trouble. The API seems a little less stable and at the time documentation was scanty but I'm told it has been fleshed out more recently.
精彩评论