[zeromq-dev] Need to PUB / REQ from multiple threads

Martin Sustrik sustrik at 250bpm.com
Thu Jan 6 14:08:54 CET 2011


Hi Gaspard,

> The mutex is not process-wide but linked to a Lua context (and a zmq
> context).

What I meant was: If you don't care that all your threads would block 
each another on the mutex, you can use it.

> Reading through the code and manual or reference I could not
> find how this migration between threads is supposed to be done. The only
> reference on socket migration I found was this:
>
>      //  At this  point we migrate the log socket to the current thread.
>      //  We rely on mutex for executing the memory barrier.
>      log_sync.lock ();
>      if (log_socket)
>          log_socket->send (msg_, 0);
>      log_sync.unlock ();
>
> Appart from locking, I do not see any "plug" or "unplug" method called.
> How is this supposed to be done ?

You don't need any special functions. The lock should do (it executes 
the memory barriers needed).

Martin



More information about the zeromq-dev mailing list