[zeromq-dev] Should I replace mutex using ZMQ?
Pieter Hintjens
ph at imatix.com
Tue Apr 15 08:55:30 CEST 2014
On Tue, Apr 15, 2014 at 5:23 AM, Dong Mo <montedong at gmail.com> wrote:
> But my question is that how should I exactly transform from the notion of
> mutex, conditional variable and etc to the thinking pattern of zmq.
This is a good question, and not often asked.
What you are talking about is transforming a hierarchical system into
a network system. That is, a pyramid of threads locked together by
some shared state, into a cluster of threads that send each other
messages.
Making such changes is impossible without a full redesign. The best
thing to do is first learn the new model really well -- take the
multithreaded examples from the Guide, try them, adapt them, and use
them -- and then come back to your original problem and re-solve it.
Using message passing instead of locks will almost always give you a
much simpler, more elegant solution. However you cannot simply do a
global search and replace and hope to make things work.
-Pieter
More information about the zeromq-dev
mailing list