如何通过boost::interprocess::message_queue
发送c ++类对象?
有人可以将使用IPC数据作为类对象的boost::interprocess::message_queue
共享IPC实现的示例代码吗?
答案 0 :(得分:0)
How can i send c++ class object via boost::interprocess::message_queue?
//Class Defination
#define MQ_DATA IPCMsg
class IPCMsg
{
public:
IPCMsg() { data = NULL; }
int len;
void* data;
};
// Initialize message Queue
mSendMq = new message_queue(OPEN_OR_CREATE, "MQ", 1024, sizeof(MQ_DATA));
mReceiveMq = new message_queue(OPEN_ONLY, "MQ");
// Send Data to message Queue
MQ_DATA* inData = new IPCMsg();
mSendMq->send(inData, sizeof(*inData), 0);
// Receive Data from message Queue
MQ_DATA* outdata = NULL;
mReceiveMq->receive(&outdata, sizeof(*outdata), 1024, priority);