[zeromq-dev] Client API with zactor

Osiris Pedroso opedroso at gmail.com
Fri Jan 19 23:38:53 CET 2018

Peter used to say that the way to handle threaded code was to send a
message that only the intended thread processed, therefore all the
interactions would be executed in that thread's context.

On this page (http://zeromq.org/intro:read-the-manual) there is a link to
this paper (close to the bottom)
Backgrounders and Whitepapers

   - Pieter Hintjens and Martin Sustrik explain
   <http://www.zeromq.org/whitepapers:multithreading-magic> how ZeroMQ
   solves the challenge of creating large multicore applications in any
   language. Also in PDF (8 pages)

See if this is what you are looking for.

On Fri, Jan 19, 2018 at 2:52 PM Kevin Wang <kevin at spikegadgets.com> wrote:

> Hello everyone,
> I am building a client API that abstracts away sockets and the Zeromq
> and CZMQ layer. To do that, my class has a zactor containing a zloop,
> polling on all the various sockets in the class.
> I eventually want my users to define their own "events", which are
> messages containing an event name (string) and associated data in the
> next frame, and for them to write their own functions that are called by
> the zloop when their messages arrive. I am doing this by creating a
> virtual function for them to override, which they can use to define
> their own behavior.
> And everything was good, until I realized that their defined function
> would be called in the zactor thread, not the user's thread. If they
> chose to define their function to change some variable or call some
> other function, that would cause a race condition.
> At least, that is what I think could happen. I realize that this is only
> loosely related to zeromq, and more about API design, but is there
> anyone else that has run into this problem? Is this a valid concern?
> My proposed solution would be to push these event messages to the user
> thread, and make the user call a processEvents() function when they can,
> which pulls the event messages and acts on them.
> Similar to:
> while(!quitCondition){
> client.processEvents()
> //Run other code
> }
> I am new to dealing with threads and am not sure if this is a common
> pattern, or if there is something basic I am missing.
> Thanks
> Kevin
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> https://lists.zeromq.org/mailman/listinfo/zeromq-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20180119/1dd7ff41/attachment.htm>

More information about the zeromq-dev mailing list