
Srinivas Gardas escribió:
Hi, I am a little confused about how to make 'interprocess_mutex' part of the 'managed_shared_memory' object which actually represents the shared_memory? Is there a base class or something that can take the mutex?
I placed an '*interprocess_mutex*' as a member variable *in the class that contains my 'managed_shared_memory'* object as a member variable and was locking it in the methods that accessed the shared memory. I guess this did not work out as I believe what I did effectively locked the object of my class that was holding the embers. And since this is not actually the shaed resource between the processes it didn't work out..
I'd really appreciate if you could provide an example of just show me bbased on my initial code.. how the 'managed_shared_memory' can be locked using the mutex.
Sreenu
Just create the mutex like you create the list and use scoped_lock to
lock and unlock it more easily (pseudo_code, not compiled):
using namespace boost::interprocess;
interprocess_mutex *mut = m_shMemPtr->find_or_construct