libcppa  Version 0.8
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
Dominik Charousset <dominik.charousset (at)>


This library provides an implementation of the actor model for C++. It uses a network transparent messaging system to ease development of both concurrent and distributed software.

libcppa uses a thread pool to schedule actors by default. A scheduled actor should not call blocking functions. Individual actors can be spawned (created) with a special flag to run in an own thread if one needs to make use of blocking APIs.

Writing applications in libcppa requires a minimum of gluecode and each context is an actor. Even main is implicitly converted to an actor if needed.

Getting Started

To build libcppa, you need GCC >= 4.7 or Clang >= 3.2, and CMake.

The usual build steps on Linux and Mac OS X are:

Hello World Example

#include <string>
#include <iostream>
#include "cppa/cppa.hpp"
using namespace std;
using namespace cppa;
void mirror() {
// wait for messages
// invoke this lambda expression if we receive a string
on_arg_match >> [](const string& what) -> string {
// prints "Hello World!" via aout (thread-safe cout wrapper)
aout << what << endl;
// terminates this actor ('become' otherwise loops forever)
// reply "!dlroW olleH"
return string(what.rbegin(), what.rend());
void hello_world(const actor_ptr& buddy) {
// send "Hello World!" to our buddy ...
sync_send(buddy, "Hello World!").then(
// ... and wait for a response
on_arg_match >> [](const string& what) {
// prints "!dlroW olleH"
aout << 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
// run cleanup code before exiting main

More Examples

The Math Actor Example shows the usage of receive_loop and arg_match. The Dining Philosophers Example introduces event-based actors and includes a lot of libcppa features.