Thanks so much Ion!
It worked fine.. now I just have to wait and see that my problem doesn't
arise again..
Sreenu
On 1/10/08, Ion Gaztañaga
Hi, I am a little confused about how to make 'interprocess_mutex' part of
'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
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
Srinivas Gardas escribió: the that 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
("PROCESS-SHARED MUTEX")(); struct_a stOne; strcpy(stOne.sym, "ABCDE"); strcpy(stOne.desc, "FGHIJK"); stOne.price = 10.25;
{ //Begin of locked scope
//Now lock the mutex to protect concurrent access //to the list scoped_lock
locker(*mut); //Do the operation m_pList->push_back(stOne);
//Mutex will be unlocked by locker's destructor } //End of locked scope
The other process should also lock the same mutex when operating with the list so that one process is blocked while the other one is manipulating the list. There are several alternatives to build the mutex in the segment but I think this is the simplest one.
Regards,
Ion _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users