|
Boost Users : |
Subject: [Boost-users] [Interprocess] Problem reading or wrting to shared memory
From: Thomas.Schulze_at_[hidden]
Date: 2009-09-07 08:43:20
Hello,
I created a simple class for storing information
in shared memory (native Windows):
template<
class data>
struct SharedData
{
SharedData<data>():
value(0),
var(0.0),
written(1),
read(0){
std::cout<<" Objekt bei "<<this<<" erzeugt!"<<std::endl;}
int value; // just temporary, will be replaced by a more generic data
type
double var; // just temporary, will be replaced by a more generic data
type
boost::interprocess::interprocess_semaphore written,read;
};
I created and mapped
that memory like:
boost::interprocess::windows_shared_memory shm (create_only,name,
read_write,sizeof(SharedData<data>));
boost::interprocess::mapped_region region(shm,read_write);
and assigned a new data structure to it's address with:
pShared = new(region.get_address()) SharedData<data>();
with pShared:
SharedData<data>* pShared;
But when I try to access the stored data with this pointer
my program simply quits.
Probably I am making a really silly mistake?
Kind regards,
Thomas
Tel.: +49 2762 408-0
Fax.: +49 2762 408-10
Internet: http://www.camcoaudio.com
CAMCO Produktions- und Vertriebs-GmbH für Beschallungs- und Beleuchtungsanlagen - Fischpicke 5 - 57482 Wenden - Amtsgericht Siegen HRB 7075 - Geschäftsführer: Joachim Stöcker, Reiner Sassmann, Carsten Wegner
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