On Feb 25, 2011, at 3:51 PM, Michael Kogan wrote:

> I was thinking that the additional method would take both a socket and an int 
> to make sure that the socket its removing is correct, since it is possible 
> that unregister was already called and another socket registered in its place.
> As a general issue - is it a problem that registering/unregistering is not 
> thread safe? I am building something like a reactor and trying to use the 
> same thread that is doing the polling and dispatch to also receive commands 
> that affect the poller state (like registering/unregistering). Does that make 
> sense to you guys?

If you are building a reactor, then all of these operations will happen 
single-threaded and you don't need to worry about a race condition. That's the 
nice thing about reactors.

If you are using multiple threads to interact with your reactor, then you're 
actually building something else. If you're worried about a race condition, 
just make your calls to register/unregister synchronized or put your own 
mutex/lock around them.

cr

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to