[zeromq-dev] C++ high level binding
Martin Lucina
martin at lucina.net
Thu Nov 3 17:03:10 CET 2011
ph at imatix.com said:
> On Thu, Nov 3, 2011 at 4:46 PM, Martin Lucina <martin at lucina.net> wrote:
>
> > I also prefer libraries to do one bit and do it well, Pieter is more a
> > one-hammer-for-everything kind of guy, sometimes.
>
> Well, CZMQ literally emerged from the Guide examples as a necessary
> layer to write simpler 0MQ apps in C. I'm not sure how you could do it
> simpler. Certainly writing 5 libraries instead of 1 would not be
> simpler. There is no code in CZMQ that's not used.
I didn't mean write X libraries; I'm just saying that not every language
binding neccessarily needs to provide threading and portability
abstractions since the language may already have accepted alternatives of
its own in place.
> > Regarding SO_LINGER/blocking zmq_term(), it is a matter of opinion.
> > Technically, your application will only block forever on zmq_term() if you
> > have outstanding messages which cannot be sent anywhere.
>
> Nope, it will block if you have open sockets, even without pending
> messages. Try creating a socket, then terminating. It hangs.
You're supposed to close the socket and then terminate the context. A
language with GC or refcounted memory management will of course do that
automagically in the right order on exit.
There's nothing wrong with your approach, but the kind[1] of C++ Ilya is using
has abstractions for resource management, so there's no need for the
library to provide its own.
-mato
[1] Everyone uses a different subset, hence some people will like the
lowlevel zmqcpp, some will want a different abstraction. Just as for C.
More information about the zeromq-dev
mailing list