5

In the C++ project I am working on, we have an application consisting of several processes deployed on different machines. This network of processes is dynamic since processes (clients or background services) can be started and terminated during the application's lifetime.

We have already a module that allows to transport arbitrary data over the network through RPC, and we are using it to exchange information (such as status information, progress information, error codes, etc) between the processes. We would like to have a more abstract layer to handle asynchronous communication (currently, the RPC is executed synchronously), and to allow processes to be started and terminated dynamically and still find each other.

We recently looked for a solution and we think we can use something like Scala actors and remote actors (see e.g. this tutorial). Another language using the actor model that has been around longer than Scala is Erlang (see also this question).

Actors are objects that have a behaviour and a mailbox, share no data. Actors are executed concurrently, and communicate through asynchronous message exchange. As part of their behaviour, actors can create other actors. Messages are also represented as objects.

The simplest case is that actors live in the same process. In this case they can address each other using a handle (reference, pointer, unique identifier). The actor implementation hides the underlying threads and any other details. When actors live in different processes (and possibly on different machines in a network) they are identified by an IP address, a port and a name. In this case we speak of remote actors (see the short example at the top of this page).

In our case, we would have one actor on each process, taking care of all the communication, i.e. we need some kind of remote actors.

On wikipedia I have found some links to actor libraries for C++ and I have started to look at Theron. Theron seems a very well-written and documented library but, to my understanding, it does not support remote actors: all actors must live within the same process. It is possible to create several actor pools (frameworks), but all these pools must live in the same process.

So I wanted to ask if someone knows other C++ libraries that support the remote actor concept as sketched above.

EDIT

This question has been edited wrt the original question, following indications from programmers-meta discussion.

UPDATE

Other frameworks I have looked at are libcppa (should support remote actors, but it is still under development, currently version 0.1), actor-cpp (also under development), and libactor, which is in C (the web site says it "is usable, although it may not be ready for production").

Giorgio
  • 19,486
  • 16
  • 84
  • 135
  • This question has already a discussion on meta, and an accepted answer. But it has been later been closed and recently got an (unexplained) downvote. I would like to delete this question but the system advises me not to do so. What am I supposed to do? – Giorgio Sep 22 '14 at 06:42

3 Answers3

7

As of version 5, Theron does support remote actors. Support is still quite preliminary and there are some limitations, notably message serialization is currently just a bitwise copy (in version 5.0, and as of October 2012). But it's a start, and I intend to develop it further.

http://www.theron-library.com/index.php?t=page&p=distributed%20computing

Ash
  • 86
  • 1
  • 1
2

Microsoft's latest "cloud-based client-server communication in native code using a modern asynchronous C++ API design", Casablanca is designed for this.

Actors

Another aspect of Casablanca is its implementation of the actor programming model, which has proven itself useful in building reliable and scalable systems. The C++ implementation stays close to the Erlang model; it’s obviously difficult to exactly mimic the model of a pure functional language in library built with an imperative language that has pointers, but we’ve gotten pretty close.

Its very new, Microsoft has only recently figured C++ is a good fit for cloud and scalable systems, but they're listening to feedback - they invited me to talk to them for an hour about it, go download it tick the "welcome feedback" box and they'll send you an email. Although its new, that doesn't mean much - MS is committed to Azure as their next big money-spinner, so this isn't going away.

gbjbaanb
  • 48,354
  • 6
  • 102
  • 172
0

Maybe the QP/C++ active object (actor) framework would fit the bill? QP/C++ has been designed primarily for real-time embedded systems, but it runs very well on Linux (with P-threads) and Windows (Win32 threads).

QP/C++ is a mature, open source framework, now celebrating 10 years on the market. It is very lightweight by design and does not support remote active objects, but this capability can be added by means of the "Remote Proxy" design pattern. In this way, you can reuse your existing communication protocol over the network(s). The benefit of using Proxies is that active objects won't know that they communicate remotely, so you can partition your system as you like without changing active objects. All you need to do is develop your Proxies.

The QP framework also provides strong support for hierarchical state machines (UML Statecharts) to model the behavior of the event-driven active objects. The framework provides an easy way to code HSMs manually in highly readable code, but you can also use the free QM modeling tool to draw statecharts and generate the QP code automatically. Please visit state-machine.com for more information.

Miro Samek
  • 121
  • 2