[zeromq-dev] Cleaning-up context creation API

Pieter Hintjens ph at imatix.com
Wed Feb 15 23:57:33 CET 2012


Hi all,

I'd like to canvas opinion for some cleanup of the ctx creation API.
This would be a backwards compatible change in accordance with
http://www.zeromq.org/docs:policies#toc2.

There are several faults with the current context API:

* It is inconsistent with the rest of the API, e.g. zmq_init for a new
context vs. zmq_msg_init vs. zmq_socket for a new socket.
* It still has that iothreads option in zmq_init, which IMO should
have gone a long time ago.
* It is not extensible, so we are seeing new experiments like
zmq_init_thread_safe().

My proposal is to make a new consistent API for contexts:

* zmq_ctx_init and zmq_ctx_term
* zmq_ctx_peek and zmq_ctx_poke to get/set options
* explicit option settings for ZMQ_IOTHREADS and ZMQ_THREADSAFE

And internally this would create the context lazily, only when the
first socket is created (so the IOTHREADS can be applied then).

There is a separate discussion about changing the functions for
get/set message options. Peek/poke are short. getctxopt/setctxopt are
messy wrt the other ctx functions.

-Pieter



More information about the zeromq-dev mailing list