
Dhanvi Kapila wrote:
Kevin Heifner wrote:
Dhanvi Kapila wrote:
So how you delete a lock ?? Is there any other safe way to delete a lock ?
I don't know what you are asking. Can you provide an example? Use the scoped lock concept. If you need to hide boost from the rest of the application then provide a wrapper around scoped lock I need to hide boost locks from the rest of my code. I have a factory class that creates locks ( we have ACE and Boost locks implemented). to create the locks, in boost, we use the new keyword and to unlock ( release the lock ) we delete the locks. The mutex object using which the locks are created are shared among the threads .
// create lock //my_mutex is a mutex factory object with b_mutex as a public member of type Boost::mutex boost::mutex::scoped_lock* lk = new boost::mutex::scoped_lock( my_mutex->b_mutex );
// deletion of lock delete lk;
is this a correct way to do this ??
If you don't mind including ACE or Boost header files whichever
you are using at the moment then something like this would work:
// file MyMutex_ACE.h
#include "ace/Synch_T.h"
struct MyMutex {
ACE_SYNCH_MUTEX mutex_;
};
#define MY_SCOPED_LOCK(M) ACE_GUARD(ACE_SYNCH_MUTEX, ace_mon,
M.mutex_)
// file MyMutex_Boost.h
#include