C++ actor 模型框架 CAF

码农软件 · 软件分类 · 并发/并行处理框架 · 2019-09-02 17:28:27

软件介绍

CAF —— C++ actor 模型框架,借鉴了 erlang 和 akka 的actor思想。使用C++现代编程规模实现。特点是:轻量级、分布式、简单、可适应以及无锁。

下载和构建:

git clone https://github.com/actor-framework/actor-framework
cd actor-framework
./configure
make
make install [as root, optional]

示例代码:

#include <string>
#include <iostream>

#include "caf/all.hpp"

using namespace std;
using namespace caf;

behavior mirror(event_based_actor* self) {
    // return the (initial) actor behavior
    return {
        // a handler for messages containing a single string
        // that replies with a string
        [=](const string& what) -> string {
            // prints "Hello World!" via aout
            // (thread-safe cout wrapper)
            aout(self) << what << endl;
            // terminates this actor
            // ('become' otherwise loops forever)
            self->quit();
            // reply "!dlroW olleH"
            return string(what.rbegin(), what.rend());
        }
    };
}

void hello_world(event_based_actor* self, const actor& buddy) {
    // send "Hello World!" to our buddy ...
    self->sync_send(buddy, "Hello World!").then(
        // ... wait for a response ...
        [=](const string& what) {
            // ... and print it
            aout(self) << what << endl;
        }
    );
}

int main() {
    // create a new actor that calls 'mirror()'
    auto mirror_actor = spawn(mirror);
    // create another actor that calls 'hello_world(mirror_actor)';
    spawn(hello_world, mirror_actor);
    // wait until all other actors we have spawned are done
    await_all_actors_done();
    // run cleanup code before exiting main
    shutdown();
}

本文地址:https://codercto.com/soft/d/13730.html

做自己:鬼脚七自媒体第一季

做自己:鬼脚七自媒体第一季

鬼脚七 / 电子工业出版社 / 2013-7 / 77.00元

当我们习惯了在社会上带着面具的时候,真实成为了一件奢侈的事情。 做到足够真实,让自己的本性表达出来,这需要勇敢。本书是鬼脚七自媒体的原创文集,主题就是做自己。本书有关于生活、互联网、自媒体的睿智分享,也有关于淘宝、搜索的独到见解,是一本接地气,文艺范,并充满正能量的电商生活书。 本书最适合淘宝卖家、电子商务人群、希望了解电商和互联网的人群阅读,也推荐热爱生活的70、80、90后阅读。一起来看看 《做自己:鬼脚七自媒体第一季》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

在线进制转换器
在线进制转换器

各进制数互转换器

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具