[zeromq-dev] 0MQ 3.0 - API improvements
Pieter Hintjens
ph at imatix.com
Fri Apr 8 13:20:18 CEST 2011
On Fri, Apr 8, 2011 at 1:10 PM, Martin Sustrik <sustrik at 250bpm.com> wrote:
> 1. Compile time checking. POSIX doesn't have it (fd is a generic int). 0MQ
> has none so far. However, if people are enthusiastic about writing
> zmq_context_t *ctx = zmq_context (1);
It's what I'd want, as a C developer. Yes, it's a little more to type,
but it lets me build type-safe functions, structures, etc.
You'd have to change the type for zmq_init, zmq_term, and zmq_socket.
My reason is not philosophical, this problem has hit me several times
over the last days, and it's annoying, and risks leaving bugs in the
code.
Actually, what I'd really like is a decently class-oriented API, i.e.
zmq_context_t *ctx = zmq_context_new ();
zmq_context_set_iothreads (ctx, 3);
zmq_context_set_trace (ctx, 1);
zmq_context_destroy (&ctx);
etc. You can do what libzapi does, and delay the creation of the IO
thread(s) until a first socket is created. That lets you configure the
context.
I'd also add, until 0MQ moves into the kernel, zmq_sock_t *sock =
zmq_socket (ctx);
> 2. Run time checking. POSIX does that. 0MQ does not. We could add that,
> especially as it requires no change to API.
Yes, you could add this, if anyone says they need it. If you
> It should be noted that the two are not mutually exclusive.
Though runtime checking only makes sense if you're using int sockets,
which you're not (yet).
There are other runtime checks you can make, e.g. that objects are
validly initialized. We did this in OpenAMQ, if you recall, and it was
useful there. But I've rarely seen people report errors with 0MQ that
this would solve.
-Pieter
More information about the zeromq-dev
mailing list