[zeromq-dev] CZMQ "actor" implementation

Pieter Hintjens ph at imatix.com
Thu May 15 22:06:07 CEST 2014

Hi all,

Just to shout out that CZMQ now has a zactor class that does a feeble
imitation of actors. I use threads, so don't start millions of actors.

The zactor class is a lot like the attached threads from zthread_fork,
with a better API. We use zsock so there are no contexts to pass
around. You talk to an actor by sending it messages, rather than via
functions. And zactor_t objects behave like zsock_t objects, you can
pass them to all methods that accept sockets:

    zactor_t *actor = zactor_new (echo_actor, "Hello, World");
    assert (actor);
    zstr_sendx (actor, "ECHO", "This is a string", NULL);
    char *string = zstr_recv (actor);
    assert (streq (string, "This is a string"));
    free (string);
    zactor_destroy (&actor);

(from the zactor_test case).


More information about the zeromq-dev mailing list