[zeromq-dev] CZMQ: why aren't zframes reference counted?
Goswin von Brederlow
goswin-v-b at web.de
Mon Sep 1 14:57:37 CEST 2014
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
More information about the zeromq-dev
mailing list