
Jan Stetka wrote:
Does the shared memory get destroyed when theses types go out of scope or am I safe with local instances, if so I don't need the default constructors. You've designed the library so well that it is showing problems in my coding style :-)
Sorry, I don't understand very well this point. Shared memory is never destroyed until explicitly removed, but it must be reopened if the shared_memory_object object is destroyed: //Imagine a default constructor is available: managed_shared_memory global_shm; void func(bool false_is_open_true_is_create) { if(false_is_open_true_is_create){ managed_shared_memory shm(create_only, "name", MemSize); global_shm.swap(shm); } else{ managed_shared_memory shm(open_only, "name", MemSize); global_shm.swap(shm); } //global_shm is usable here because it has been swapped //with a correctly opened instance global_shm.create<>(...); } If global_shm is destroyed. Shared memory is still in the system, although not mapped. To destroy it, you must explicily call shared_memory_object::remove("name"); If global_shm is destroyed you can reopen it can using managed_shared_memory shm(open_only, "name", MemSize); Regards, Ion