Boost logo

Boost Users :

From: Dhanvi Kapila (boostguy_at_[hidden])
Date: 2006-02-16 19:32:34


Hi :
 I have this piece of code for mutex operations. is this code
thread-safe ? I plan to use this code in threads...
------------------------------------
class BoostMutexLock
{
   public :
        void lock() {
               lk = new boost::mutex::scoped_lock(global_mutex);
       }
        void unlock() {
              delete lk;
        }
  BoostMutexLock() : lk( 0 ) { }
  ~BoostMutexLock() { }

private:
      boost::mutex global_mutex;
      boost::mutex::scoped_lock* lk;
};
------------------------------------------------------
I appreciate all the help.. How do I know to check for thread-safety in
a code ? Are there any documents? I have checked online and have some
links, but havent found documents which provide examples and explain..
such a document would be really useful.

Thanks...
Dhanvi


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net