[zeromq-dev] Thread creation location in source

Kenneth Adam Miller kennethadammiller at gmail.com
Sun Jan 12 13:56:21 CET 2014

I was told that it is in the context creation that threads are created, but
so far I haven't found it.

I looked through the zmq.cpp file's new_context_t function, which is called
to construct a new context just as I was told.

new_context_t had nothing to do pertaining to thread creation, so I traced
it down to the ctx_t object constructor. I found that it set some
parameters to default values, and that it didn't descend from another
object but that all of these parameters were not threads. The body of the
ctx_t constructor contains only getpid.

It isn't until you get into the socket creation part that it starts
creating threads. But these are io_thread_t types. I went into it's
constructor and found that it doesn't create any threads. It isn't until
I've gotten to the thread.cpp files that I see threads creation of the type
where concurrency really occurs. I may not have found the right place yet
in source (there's a lot, & I'm new), but is that where I need to start, in

It doesn't make sense to me, because I even went so far as to compile and
run the hellow world server and client examples, and to place some cout
calls in the appropriate constructors:

std::cout << "Hooha" << std::endl;    //in io_thread.cpp io_thread_t
constructor, which it showed


std::cout << "har har" << std::endl;  //in thread.cpp thread_t start

I even put a few lines in the constructor of thread_t objects. I still
can't for the life of me find the place where internal background threads
get started by zmq!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140112/92e3ba24/attachment.htm>

More information about the zeromq-dev mailing list