[zeromq-dev] Context wrangling
Pieter Hintjens
ph at imatix.com
Wed Apr 23 08:56:07 CEST 2014
Hi Scott,
> The description ends with "Do not destroy the ctx, the thread
> does this automatically when it ends."
Do not destroy it in the child thread, it should say. The parent
thread should destroy the context as usual.
zthread_fork() keeps a single 0MQ context so threads can talk over inproc://
zthread_new() creates a detached thread that can create its own 0MQ
contexts as if it was a separate process.
> There doesn't seem to be a zthread_join, so the
> threads get terminated at random times w.r.t. one another.
Right... this is perhaps lacking.
You always want a zctx_new() and zctx_destroy() in the same thread. If
a thread isn't calling zctx_new() it should not call zctx_destroy().
-Pieter
More information about the zeromq-dev
mailing list