[zeromq-dev] Socket use from several threads

moteus mimir at newmail.ru
Wed Jul 18 09:49:08 CEST 2012


Chuck Remes <lists <at> chuckremes.com> writes:


> Oh, so the threads are short-lived then. In that case, you should create a
pool of them and have each thread
> "check out" the socket from the pool when it needs to use it and check it back
in again when the thread exits.
> If the pool is protected by a mechanism (like a mutex) that employs a full
memory barrier, then it will be safe.

Thanks.
And one more question. 
Can I start recv in one thread but get result in other?
For example. I use DEALER socket instead REQ and get timeout on recive.
I put socket back to pool. Another thread get this socket from pool and send 
it's own request. This thread can recognize its response and ignore other
responses. 
Or better just to recreate socket like described in guide?






More information about the zeromq-dev mailing list