[zeromq-dev] Any way to make inproc type-safe?

Bjorn Reese breese at mail1.stofanet.dk
Sat Nov 16 15:11:15 CET 2013

On 11/15/2013 01:15 PM, Lindley French wrote:

> I agree this is an important concern. With a type-safe signals and slots
> library, you can just use a shared_ptr to take care of that. When you
> can't rely on type safety, you have to be a bit more clever. Probably
> you'd have to use placement new to construct a copy of the shared_ptr in
> the zeromq message, then placement delete on the other side to get rid
> of it after the receive occurs. That's the simplest way I can see to
> manage the reference count correctly.

I am not sure that this would work in all cases. When libzmq drops a
message due to the high water mark, the message will not arrive at the
other side, so the reference count will not be decremented.

We would probably need some kind of callback when messages are dropped
for that situation. Only then can we get the desired life-time
guarantee using something like boost::intrusive_ptr.

More information about the zeromq-dev mailing list