title: boost::mutex::~mutex(): Assertion `!pthread_mutex_destroy(&m)' failed
body: <p>I got the captioned error in the mutex destructor. since the error may due to the mutex is in lock state during destruction, I create a new mutex class which is inherited from boost:mutex. it is to make sure the mutex is unlock during destruction. However, the same error still occurs.
  Any hits would be appreciated!</p>
  
  <pre><code>class CMutes : public boost::mutex
  {
  public:
      CMutes()
      {
  
      };
  
      virtual ~CMutes()
      {
          if (m_bLock)
              boost::mutex::unlock();
      };
  
      void lock()
      {
          if(!m_bLock)
              boost::mutex::lock();
          else
              cout &lt;&lt; "Mutex is in lock state\n";
      };
  
      void unlock()
      {
          if (m_bLock)
              boost::mutex::unlock();
          else
              cout &lt;&lt; "Mutex is in unlock state\n";
      }
  
      boost::mutex&amp; getMutex()
      {
          return *this;
      }
  
  private:
  
      bool m_bLock;
  };
  </code></pre>
  
  <p>EDIT:
  Yes you are right. I should use RAII. However, I am in a situation. I need to lock a resource before another thread is finish processing it. something like below.</p>
  
  <pre><code>Thread A:
  void getDate()
  {
   m_oLock.lock();
   // access resource
  }
  
  void unlock()
  {
   m_oLock.unlock();
  }
  Thread B:
  void Process()
  {
   threadA.getData();
   threadA.unlock();
  }
  </code></pre>