[zeromq-dev] CZMQ: why aren't zframes reference counted?

Pieter Hintjens ph at imatix.com
Mon Sep 1 16:14:44 CEST 2014

There is an option on zframe_send (ZFRAME_REUSE) which side-steps the
destruction. It's a simple exception that lets you send the same frame
many times, without the machinery of reference counting, duplicating,

On Mon, Sep 1, 2014 at 2:57 PM, Goswin von Brederlow <goswin-v-b at web.de> wrote:
> Hi,
> the zframe_t type is based on the zmq_msg_t type. But while zms_msg_t
> uses reference counting there is no function to clone a zframe_t using
> a shared zmq_msg_t object. Consequently there is no way to make a
> shallow copy of a zmsg_t (which holds a zlist of zframe_t).
> Also sending a zmsg_t is destrutive. I need to send the same message
> (except different identity frame at the start) to many peers and
> possibly resend it when a peer reconnects. Currently that means
> duplicating every message many (100-1000) times which wastes both ram
> and cpu a lot.
> Any objections to adding three functions:
> // create new zframe_t that shares the same content as frame
> zframe_t * zframe_clone (zframe_t *frame);
> // create new zmsg_t that is a shallow copy of msg
> // frame contents are shared, see zframe_clone
> zmsg_t * zmsg_shallow_dup (zmsg_t *msg);
> // Send message to socket, but do not destroy after sending.
> int zmdg_send_keep (zmsg_t *msg, void *dest);
> MfG
>         Goswin
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

More information about the zeromq-dev mailing list