[zeromq-dev] Using polling with zactor in C

Robert Johnston robert at layer2.com
Sat Dec 12 21:28:29 CET 2015



I had an application using 0mq V3.x that used zthread_fork to create workers
with sockets to the outside world. The threads used zmq_poll to catch events
from the main application and the sockets.


Now I have updated to V4.2.0 and trying to re-do the application the zactor
way. And not having much luck with polling.


As a simple test, I used the echo test with polling added to echo_actor
(partially shown below). Nothing happens.  If I comment out the "if
(items[0] ." line, the test runs.


What am I missing? Does zactor require a different polling method? Can you
point me to an example?


Any and all comments, suggestions, praise, or blame gratefully accepted.







//  Actor

//  must call zsock_signal (pipe) when initialized

//  must listen to pipe and exit on $TERM command



echo_actor (zsock_t *pipe, void *args)


   zmq_pollitem_t items[] =


      {pipe, 0, ZMQ_POLLIN, 0}



   //  Do some initialization

   assert (streq ((char *) args, "Hello, World"));

   zsock_signal (pipe, 0);


   bool terminated = false;

   while (!terminated) {

      zmq_poll (items, 1, 0);


      if (items[0].revents & ZMQ_POLLIN)



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20151212/23633079/attachment.htm>

More information about the zeromq-dev mailing list