The reason the Guide discourages this is because when you start thinking in terms of "share this socket between threads", your application design goes down the drain. The only exception is for language bindings (not applications) where it's literally impossible to do any other way.
-Pieter On Thu, Jan 3, 2013 at 1:08 AM, Nishant Mittal <[email protected]> wrote: > Joshua, if you read my first msg in this thread you'll see that its > guaranteed by application logic.. 5 threads at a time.. 5 different > sockets.. each thread only uses its own socket... the only issue i wanted > to check was that the sockets were not created "by the thread" thats going > to use them .. which the guide discourages.. > > > > On Wed, Jan 2, 2013 at 7:03 PM, Joshua Foster <[email protected]> wrote: > >> The mutex is "required" because it guarantees that it is only used by a >> single thread at a time. ZMQ has assertions that will cause your >> application to crash if you access a socket between two threads >> concurrently. >> >> Joshua >> >> Nishant Mittal <[email protected]> >> January 2, 2013 6:58 PM >> 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 >> >> >> >> >> >> >> -- >> *Nishant Mittal* >> Director, Product Development >> *Rosenblatt Securities Inc*. >> 20 Broad Street >> New York, NY 10005 >> >> Direct: 212-607-3159 >> Mobile: 646-504-2629 >> _______________________________________________ >> zeromq-dev mailing list >> [email protected] >> http://lists.zeromq.org/mailman/listinfo/zeromq-dev >> >> >> _______________________________________________ >> zeromq-dev mailing list >> [email protected] >> 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 > > _______________________________________________ > zeromq-dev mailing list > [email protected] > http://lists.zeromq.org/mailman/listinfo/zeromq-dev > >
_______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
