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

Gaspard Bucher gaspard at teti.ch
Thu Jan 6 13:50:52 CET 2011


Hi Martin,

The mutex is not process-wide but linked to a Lua context (and a zmq
context). 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 ?

Gaspard

On Thu, Jan 6, 2011 at 9:48 AM, Martin Sustrik <sustrik at 250bpm.com> wrote:

> Hi Gaspard,
>
>
>  What prevents the calls from moving between threads, apart from
>> thread-safety (as I said, there is a global mutex) ?
>>
>
> Global mutex allows for migrating sockets between application threads each
> time the mutex is locked. So yes, it would work.
>
>
>  My understanding is that to avoid moving socket calls between threads, I
>> would need to push/pull inproc sockets (one PUSH for every thread, one
>> PULL for the REQ/PUB sockets) but this seems like a waist of resources...
>>
>
> Well, if you don't care about performance, single process-wide bottleneck
> created by the mutex and inability to scale out of the process/box (i.e.
> ability to change inproc to ipc or tcp in he future) there's nothing to
> prevent you to use the approach.
>
> Martin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110106/d756f794/attachment.htm>


More information about the zeromq-dev mailing list