[zeromq-dev] clarification regarding zero copy

KIU Shueng Chuan nixchuan at gmail.com
Thu May 9 04:17:35 CEST 2013


Your callback function "respawn" is called when zero mq is done with the
buffer.
On 9 May, 2013 8:50 AM, "Erdos" <covariantmonkey at gmail.com> wrote:

> Hi,
>
> I have a short bit of code to send data over a push socket via the
> zero-copy mechanism:
>
> static void respawn(void* data, void* hint){};
> int main ()
> {
>   zmq::context_t context (1);
>   zmq::socket_t socket (context, ZMQ_PUSH);
>   socket.connect ("tcp://localhost:5555");
>
>   string payload = "";
>   for (int request_nbr = 0; request_nbr != 10000; request_nbr++) {
>     payload = "boo";
>     zmq::message_t request ((void *)payload.data(), payload.size(),
> respawn); //L1
>     socket.send (request, ZMQ_NOBLOCK); //L2
>   }
>
>   return 0;
> }
>
>
> Its not entirely clear to me if I can safely assume that the buffer
> 'payload' is available to me immediately following the 'send' operation
> (L2).
>
> Does the 'send' internally copy the contents of payload on to something?
> You can see why if for some odd reason the contents are not immediately
> dealt with (i.e. zmq is still waiting to do something with payload buffer),
> then assigning new values to payload at the top of the loop is just wrong.
>
> The code block above runs just fine but I would like to be sure-- are
> there any mechanism for zmq to signal that it has finished dealing with
> payload buffer and okay for me to re-assign it?
>
> Many thanks
> Asif
>
>
>
>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130509/7edf9b92/attachment.htm>


More information about the zeromq-dev mailing list