Reputation: 2033
Is it safe to access a NetMQ
socket from multiple threads, as long as they are not using it simultaneously?
For example,
is the following scenario OK:
A
uses a socket.A
ends.B
uses the same socket.If not,
must the sole operating thread be the very same who created the socket?
Upvotes: 1
Views: 1143
Reputation: 4842
Technically you can. However how can you guarantee that it is actually not used concurrently? I suggest using a lock if you want to use the socket from multiple threads. Also take a look at NetMQQueue, is new and not documented, thread safe for enqueueing only. It might help you solve synchronization threads between NetMQ Sockets as you can poll on it with the Poller.
https://github.com/zeromq/netmq/blob/master/src/NetMQ.Tests/NetMQQueueTests.cs
Upvotes: 3