[zeromq-dev] Want to use ZMQ socket in multithreading

Doron Somech somdoron at gmail.com
Fri Jul 29 11:16:16 CEST 2016


Actually zeromq now have group of thread safe sockets: those are:
client-server,  radio-dish,  scatter-gather

On Jul 29, 2016 11:47, "Auer, Jens" <jens.auer at cgi.com> wrote:

> Hi Bharat,
>
> ZeroMQ is not rhead-safe and sockets shall not be used concurrently from
> different threads. I think there are some new socket types in the master
> branch which are thread-safe, but this not part of the release version. As
> they are not thread-safe, you cannot reliably check conditions on them when
> using them concurrently. You could use a mutex to prevent concurrent access.
>
> The recommended alternative would be to have independent theads that do
> not share data or resources communicating via ZMQ_PAIR sockets. I would
> strongly recommend to go that route as data-sharing multi-threading is a
> highway to hell. It does also often not offer the performance/scalability
> gain that you are hoping for because of congestion at the shared resources.
>
> Cheers,
>   Jens
>
> --
> *Jens Auer *| CGI | Software-Engineer
> CGI (Germany) GmbH & Co. KG
> Rheinstraße 95 | 64295 Darmstadt | Germany
> T: +49 6151 36860 154
> *jens.auer at cgi.com* <jens.auer at cgi.com>
> Unsere Pflichtangaben gemäß § 35a GmbHG / §§ 161, 125a HGB finden Sie unter
> *de.cgi.com/pflichtangaben* <http://de.cgi.com/pflichtangaben>.
>
> CONFIDENTIALITY NOTICE: Proprietary/Confidential information belonging to
> CGI Group Inc. and its affiliates may be contained in this message. If you
> are not a recipient indicated or intended in this message (or responsible
> for delivery of this message to such person), or you think for any reason
> that this message may have been addressed to you in error, you may not use
> or copy or deliver this message to anyone else. In such case, you should
> destroy this message and are asked to notify the sender by reply e-mail.
> ------------------------------
> *Von:* zeromq-dev [zeromq-dev-bounces at lists.zeromq.org]" im Auftrag von
> "Bharat Somani [bharatdsomani at gmail.com]
> *Gesendet:* Freitag, 29. Juli 2016 09:09
> *An:* ZeroMQ development list
> *Betreff:* [zeromq-dev] Want to use ZMQ socket in multithreading
>
> Hi All,
>
> I am creating socket in one thread and sharing this to be used in multiple
> threads. But when I try to use it, sometimes I get error
>
> Assertion failed: check () (src/msg.cpp:248)
>
> I was breaking ZMQ's rule of sharing sockets among threads.
>
> Is there any way to know whether the socket is currently in used (sending
> data) state? If there is a way, I can check it before sending the data.
>
>
> Regards,
> Bharat
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20160729/88001d84/attachment.html>


More information about the zeromq-dev mailing list