[zeromq-dev] context as global/static variable

Daniel Krikun krikun.daniel at gmail.com
Wed May 9 11:39:40 CEST 2012


I have some c++ code, that uses zeromq. In the code, I have a singleton
wrapping zmq::context_t, like this:

struct ctx_singleton
           zmq::context_t& instance()
                 static zmq::context_t _ctx;
                 return _ctx;

At application shutdown, I get an assertion failure:
  Successful WSASTARTUP not yet perfromed (..\..\..\src\signaler.cpp:124)

I suspected there was a problem w/ zmq::context_t having global storage, so
I just take some zeromq sample and moved context definition from main into
global scope, and yes, I yields the same failure. I looked at the stack
trace, it seems that some socket/synch. mechanism is already disposed when
zmq_term is invoked and thus the failure.

I really would like to put zmq::context_t instance, just to make things
easier, and not to pass the instance to all threads. Is there a possibility
to do so?

I'm using zeromq-2.1.11, visual studio 2008 on Windows XP sp3, 32-bit.


Daniel Krikun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120509/59c9efc6/attachment.htm>

More information about the zeromq-dev mailing list