c++ - Boost interprocess_mutex copy/move constructor? -


i'm trying create vector of objects in shared memory each own interprocess_mutex 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 explicitly missing copy/move constructor , clang fails compile error:

copy constructor of 'test' implicitly deleted because field 'mutex' has inaccessible copy constructor interprocess_mutex mutex; 

is there reason this? looks boost::thread mutex has copy constructor. how can accomplish using interprocess_mutex?

no standard or boost mutex-type class provides copy constructor. if need copy classes containing mutex member, mutex needs turned pointer, , need provide copy constructor deal mutex appropriately.

what copying mutex do? both instances refer same mutex? each instance have it's own mutex? if mutex locked during copy?

aside these questions, mutex member used protect object's other members. if support copying on class mutex member, want lock mutex @ point during copy.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -