Boost logo

Boost Users :

Subject: [Boost-users] boost::Interprocess sharing objects using virtual inheritance
From: Martin Kaiser (martin_at_[hidden])
Date: 2009-09-16 18:51:27


hi,

I am currently developing an API for PCI devices. Multiple processes
should be able to use the API simultaniously, but there may be only one
instance of the API and all processes have to use that same instance.

So I decided to use a shared memory with a vector containing all
instances of the PCI device Objects.

The Problem is that my PCI Device Object uses virtual inheritance and
the doc of boost::interprocess says that it isn't possible (see below).

Now I am wondering if it's possible to store an offset_ptr or a kind of
Ownership smart pointer in that vector pointing to my virtual inherited
Device Object in a Managed Memory Segment (not memory mapped region!).

Can anybode give me a hint on this?

Thank in regards

Martin

 
from
http://www.boost.org/doc/libs/1_39_0/doc/html/interprocess/sharedmemorybetweenprocesses.html
:

Virtuality forbidden

The virtual table pointer and the virtual table are in the address space
of the process that constructs the object, so if we place a class with a
virtual function or virtual base class, the virtual pointer placed in
shared memory will be invalid for other processes and they will crash.

This problem is very difficult to solve, since each process needs a
different virtual table pointer and the object that contains that
pointer is shared across many processes. Even if we map the mapped
region in the same address in every process, the virtual table can be in
a different address in every process. To enable virtual functions for
objects shared between processes, deep compiler changes are needed and
virtual functions would suffer a performance hit. That's why
Boost.Interprocess does not have any plan to support virtual function
and virtual inheritance in mapped regions shared between processes.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net