<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          CAFC++ actor 模型框架

          聯(lián)合創(chuàng)作 · 2023-09-29 13:36

          CAF —— C++ actor 模型框架,借鑒了 erlang 和 akka 的actor思想。使用C++現(xiàn)代編程規(guī)模實(shí)現(xiàn)。特點(diǎn)是:輕量級(jí)、分布式、簡(jiǎn)單、可適應(yīng)以及無鎖。

          下載和構(gòu)建:

          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();
          }
          瀏覽 20
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  国产色情 免费 | 久久成人大香蕉 | 黄色18禁止网站 | 久久精品波多野结衣 | 天天五月|