title: CMutex::Lock vs. CSingleLock::Lock
body: <p>I've been tapped to support some legacy code, and I'm seeing some things that cause me to scratch my head in confusion.  In some sections of code, I see that a class instance uses a CMutex instance to synchronize method execution.  For instance</p>
  
  <pre><code>class CClassA : public CObject
  {
  public:
     void DoSomething();
  
  private:
     CMutex m_mutex;
  }
  
  void CClassA::DoSomething()
  {
     m_mutex.Lock();
  
     //...logic...
  
     m_mutex.Unlock();
  }
  </code></pre>
  
  <p>Elsewhere in the same project I find that the code is using a CSingleLock</p>
  
  <pre><code>class CClassB : public CObject
  {
  public:
     void DoSomething();
  
  private:
     CCriticalSection m_crit;
  }
  
  void CClassB::DoSomething()
  {
     CSingleLock lock(&amp;m_crit);
     lock.Lock();
  
     //...logic...
  
     lock.Unlock();
  }
  </code></pre>
  
  <p>After reviewing <a href="http://msdn.microsoft.com/en-us/library/thdxkfx9%28v=vs.80%29.aspx" rel="noreferrer">MSDN documentation for synchronization</a>, it would appear that CClassB is implementing the advised method, but it isn't clear to me what the danger is in the implementation used by CClassA.  As far as I can tell, the only difference between the two methods is that CSingleLock has the benefit of RAII, so the lock is automatically released when execution exits scope.  Are there any other benefits / drawbacks to either implementation?</p>