C++ Actor Framework — Dev Blog

An Open Source implementation of the actor model in C++

Version 0.16 Finally Released!

We are excited to announce version 0.16 of the C++ Actor Framework! Among other features and improvements, this release adds experimental support for streams.

Streams in CAF are now the fourth pillar of our communication layer and complement asnychronous messaging, publish/subscribe groups, and request/response protocols. Fundamentally, streams give you bounded queueing of pipelined messages with backpressure. This means they provide a safe channel for sending arbitrary amounts of data without worrying about overloading receivers.

Of course streams are first-class citizens in CAF. Actors can have any number of active streams and can modify existing streams at runtime, for example by adding more sources or sinks to it. This gives actors a powerful new tool that required a lot of changes under the hood. Without going into too much detail, actor mailboxes now consist of several internal queues that allow seamless multiplexing of regular actor messages and stream traffic. You can find an introduction to streams with code examples in our new manual section.

Expect your projects to run and compile after updating to 0.16, since this release brings no breaking changes. However, you might get warnings for deprecated member variables in actor_system_config. We have improved support for runtime configurations in CAF by adding lists, durations and dictionaries and made settings available by name instead of requiring access to member variables:

// Deprecated API:
auto verbosity = cfg.logger_verbosity;

// New API:
auto verbosity = get_or(cfg, "logger.verbosity", defaults::logger::verbosity);

CAF 0.16 bundles constants unter defaults::<component>. This may seem like strictly more overhead and typing at first, but now you can access custom options in the same way, without having to know the subtype in order to access some member variable. Your application could add the option database.host, for example, and you would access it directly from the system-wide config. No downcasting to the subtype of actor_config_server required.

Got no default? Use get_if or get instead. The API is modelled after C++17’s get_if, and get, i.e., you could query a parameter as follows:

auto host = get_if<std::string>(&cfg, "database.host");
if (!host) {
  std::cerr << "database host missing" << std::endl;
  // ...
} else {
  std::cout << "connect to database host " << *host << std::endl;
  // ...
}