[zeromq-dev] zmq_socket and threads

Nishant Mittal nmittal at rblt.com
Thu Jan 3 00:58:31 CET 2013


Charles.. the most relevant (to my use case) piece there is.. "For those
situations where a dedicated socket per thread is infeasible, a socket may
be shared *if and only if* each thread executes a full memory barrier
before accessing the socket. Most languages support a Mutex or Spinlock
which will execute the full memory barrier on your behalf."

However, I was wondering that given my app logic below, do I need to use
mutex etc?.. each thread is completely independent of the other.. no shared
objects.

thanks
NIshant



On Wed, Jan 2, 2013 at 5:19 PM, Charles Remes <lists at chuckremes.com> wrote:

>
> On Jan 2, 2013, at 3:23 PM, Nishant Mittal <nmittal at rblt.com> wrote:
>
> > I know that zmq_sockets are not thread safe. however, is it an issue if
> I ensure a socket is used ONLY by 1 thread at a time?
> >
> > the reason is ...
> > 1) my application creates 5 threads, does some calcs and then the
> threads exit
> > 2) this is done every minute. so every minute 5 new threads are created.
> > 3) I think i will run into a file descriptor issue if i create sockets
> inside the thread (every time the thread is launched). so planning to
> create 5 sockets when my application starts and then use 1 socket from 1
> thread.
> >
> > is this going to be an issue?
>
> This is answered quite thoroughly in the FAQ.
>
> http://www.zeromq.org/area:faq
>
> cr
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>



-- 
*Nishant Mittal*
Director, Product Development
*Rosenblatt Securities Inc*.
20 Broad Street
New York, NY 10005

Direct: 212-607-3159
Mobile: 646-504-2629
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130102/05e3bdb2/attachment.htm>


More information about the zeromq-dev mailing list