I am trying to build a memoryHandler which allows me to create and manage my shared memory, e.g. I want to create a managed_memory_object
only once.
When I construct an segment I want to actually store the return pointer as a member variable in my class, so I can access it without using the find function from boost.
Is there any way to achieve something like this or do I always have to map my shared memory and find my segment with the find function?
thank you for you help
Manu
Example Class:
MemHandler::MemHandler(const char* name_p)
{
size_m = 1024;
name_m = name_p;
shm_m{open_or_create, name_m, size_m};
sharedVar_m = shm_m.construct<int>("sharedValue")(4711);
}
int* MemHandler::getSharedVar()
{
return sharedVar_m;
}
void MemHandler::setSharedVar(int value)
{
sharedVar_m = shm_m.construct<int>("sharedValue")(value);
}