I'm trying to create a vector of objects in shared memory that each own an interprocess_mutex as follows:
struct test
{
test(){}
interprocess_mutex mutex;
};
using namespace boost::interprocess;
managed_shared_memory seg(open_or_create, "MySharedMemory", 65536);
allocator<void, managed_shared_memory::segment_manager> void_alloc_(seg.get_segment_manager());
vector<test, allocator<test, managed_shared_memory::segment_manager>> vec(void_alloc_);
vec.push_back(test());
However interprocess_mutex is explicitly missing a copy/move constructor and clang fails to compile with this error:
copy constructor of 'test' is implicitly deleted because field 'mutex' has an inaccessible copy constructor
interprocess_mutex mutex;
Is there a reason for this? It looks like boost::thread mutex has a copy constructor. How can I accomplish this using interprocess_mutex?