A trivial example program.
A trivial example program.
#include "caf/actor_ostream.hpp"
#include "caf/actor_system.hpp"
#include "caf/caf_main.hpp"
#include "caf/event_based_actor.hpp"
#include <string>
using namespace std::literals;
return {
[self](const std::string& what) -> std::string {
self->println("{}", what);
return std::string{what.rbegin(), what.rend()};
},
};
}
self->mail("Hello World!")
.request(buddy, 10s)
.then(
[self](const std::string& what) {
self->println("{}", what);
});
}
auto mirror_actor = sys.
spawn(mirror);
sys.
spawn(hello_world, mirror_actor);
}
CAF_MAIN()
Actor environment including scheduler, registry, and optional components such as a middleman.
Definition actor_system.hpp:87
infer_handle_from_class_t< C > spawn(Ts &&... xs)
Returns a new actor of type C using xs... as constructor arguments.
Definition actor_system.hpp:383
Identifies an untyped actor.
Definition actor.hpp:30
Describes the behavior of an actor, i.e., provides a message handler and an optional timeout.
Definition behavior.hpp:24
A cooperatively scheduled, event-based actor implementation.
Definition event_based_actor.hpp:31
Root namespace of libcaf.
Definition abstract_actor.cpp:23