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

推荐系统与深度学习

推荐系统与深度学习

黄昕、赵伟、王本友、吕慧伟、杨敏 / 清华大学出版社 / 2019-1-1 / 65.00元

本书的内容设置由浅入深,从传统的推荐算法过渡到近年兴起的深度学习技术。不管是初学者,还是有一定经验的从业人员,相信都能从本书的不同章节中有所收获。 区别于其他推荐算法书籍,本书引入了已被实践证明效果较好的深度学习推荐技术,包括Word2Vec、Wide & Deep、DeepFM、GAN 等技术应用,并给出了相关的实践代码;除了在算法层面讲解推荐系统的实现,还从工程层面详细阐述推荐系统如何搭建.一起来看看 《推荐系统与深度学习》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具