What I'm trying to do is an application. Send application B to the pointer to the object that A allocated in shared memory (using boost :: interprocess). For this passing pointer I intend to use boost::interprocess::message_queue. Obviously, the direct raw pointer from A is not valid in B, so I am trying to pass offset_ptrallocated in shared memory. However, this also does not work.
Process A does the following:
typedef offset_ptr<MyVector> MyVectorPtr;
MyVectorPtr * myvector;
myvector = segment->construct<MyVectorPtr>( boost::interprocess::anonymous_instance )();
*myvector = segment->construct<MyVector>( boost::interprocess::anonymous_instance )
(*alloc_inst_vec); ;
mq->send(myvector, sizeof(MyVectorPtr), 0);
Process B does the following:
MyVectorPtr * myvector;
myvector = segment->construct<MyVectorPtr>( boost::interprocess::anonymous_instance )();
mq->receive( myvector, sizeof(MyVectorPtr), recvd_size, priority);
As I can see, in this way make a small copy of the offset pointer, which makes it invalid in process B. How do I do this correctly?
source
share