Friday, February 21, 2014

Prerelease of Version 0.9

Version 0.9 of libcppa is just around the corner – and it's not simply an incremental update but a redesign of many (in fact: most) parts of libcppa. Since we don't plan to make any more changes to the API, we've decided to do a prerelease. This gives us the opportunity to get feedback from the community while polishing the remaining parts of the library and it also gives you the opportunity to start porting your code to 0.9 early.

The most important changes:
  • self has been removed
    This is the biggest change and in fact did cause a lot of redesign and implementation work. The major problem with this keyword-like identifier is that it must have a single type, because it's implemented as a thread-local variable. Since there are so many different kinds of actors (event-based or blocking, untyped or typed), self simply isn't useful anymore. It could only point to the address (see below) of an actor, but this isn't useful at all, because we cannot get the type information we need. Instead of a thread-local pointer, you can now use the first argument in functor-based actors to "catch" the self pointer – with proper type information.
  • actor_ptr has been removed/replaced
    The name actor_ptr bothered me for long time now, because it's misleading. The fact that libcppa uses pointers behind the scenes to keep things fast should not be exposed in the API. However, that was not the reason for the change. libcppa now distinguishes between handles to actors, i.e., typed_actor<...> or actor, and addresses of actors, i.e., actor_addr. The reason for this change is that each actor has a logical, (network-wide) unique address, which is used by the networking layer of libcppa. Furthermore, for monitoring or linking, the address is all you need. However, the address is not sufficient for sending messages, because it doesn't have any type information. The function last_sender() now returns the address of the sender, meaning that send(last_sender(), ...) will cause a compiler error.
  • The API for typed actors is now similar to the API for untyped actors
    Although there are some minor differences (typed actors cannot use guard expressions for instance), the APIs are quite similar. You can use function-based or class-based actors, you can "catch" the self pointer in the same way, and you can change the behavior by calling become(...).

Issues (or: why this isn't a final release yet):
  • No scheduling
    The prerelease does not include a scheduler. Instead, each actor is always mapped to a thread, whether or not you use the detach flag. So... don't expect good performance when running many actors.
  • Documentation incomplete
    The manual has been revised, but doesn't include all new features. The same is true for the Doxygen-generated documentation.
  • Testing
    The unit tests of libcppa cover most of the new features, but there's still work to do.

As always, please don't hesitate to get in touch if you've found a bug, miss a feature, couldn't find something in the documentation, or simply have a question.