[zeromq-dev] Something's broken in session_base or there's something I really ought to know about multithreading.
Claudio Carbone
erupter at libero.it
Mon Jan 14 13:56:29 CET 2013
I managed to understand an important detail:
the problem arises from how I pass parameters to the child thread.
If I just pass a void pointer to the zmq context, all is fine.
If I pass a pointer to my struct (with explicit castings on both sides),
the problems shows its head.
Now I don't know enough to understand this, I hope someone more
knowledgeable can chime in.
Here are the two possibilities
working
void *zmq_cont_ptr = zmq_ctx_new();
pthread_create(&th_hndl_subber, NULL, th_subscriber, zmq_cont_ptr);
non working
typedef struct parameters{
//Zmqcpp::Context * zmqcont;
void * zmqcont;
void (*callback) (std::string);
std::string ip;
int conntype;
std::list<std::string> topics;
}parameters;
parameters myparams;
pthread_create(&th_hndl_subber, NULL, th_subscriber, (void *)&myparams);
void * th_subscriber(void * params)
{
parameters *myparameters = (parameters *) params;
Claudio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130114/c5b19a77/attachment.htm>
More information about the zeromq-dev
mailing list