Quantcast
Channel: Active questions tagged zeromq - Stack Overflow
Viewing all articles
Browse latest Browse all 193

How to delete flatbuffers received from ZeroMQ

$
0
0

I'm looking for an example in C++ 11 to delete flatbuffers received by ZeroMQ.

I have two applications: Publisher and Subscriber.I know that on the Publisher (sender) side, that the FlatBufferBuilders I use are RAII. Those work. But on the receiver side, do these flatbuffer messages clear themselves in some way? I think I need to move or copy each message. I'm not sure sure how that should be done exactly (API methods? memcpy? make my own wrapper objects?). There are no good examples for what I need with both flatbuffers and ZeroMQ PUB/SUB - I've looked.

zmq_msg_close, non-deterministic when it does anything, and it adds to the confusion. According to zmq docs, it cleans resources after the user has "indicated" it is no longer needed. Could it possibly step on messages I need to store in a temp data structure to use later in the program?

SUBSCRIBER APP (C++ app, but psuedo codish representation here for simplicity) ... repeat in a while(1) loop ...

zmq_msg_t zMsg;zmq_msg_init(&zMsg);int numBytesReceived = zmq_msg_recv(&zMsg, subSocket, 0);if(numBytesReceived != -1){   const my::fbs::MyMessage * myReceivedMessage =      my::fbs::GetMyMessage(zmq_msg_data(&zMsg));   //switch on MessageType (union)   const my::fbs::SelectedSubMessage * pSSM = myReceivedMessage->get_content_as(CaseType);   // **How to eventually delete the fbs messages later in the program?   // move them into something else? copy them? use flat cpp gen objects "T"? DetachedBuffer? or leave them as is?**}zmq_msq_close(zMsg); 

I have written client/server, pub/sub test apps.Each time I would watch memory size by procid.I would determine if memory size decreased after zmq_msg_close - it does not (but zmq_msg_close is not deterministic I know)I can't call delete explicity on the received flatbuffer. They are "owned" as subclasses of private Table.


Viewing all articles
Browse latest Browse all 193

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>