title: "Nested" scoped_lock
body: <p>My shortened, simplified class looks as follows:</p>
  
  <pre><code>class A
  {
      public:
      // ...
      methodA();
      methodB();
  
      protected:
      mutable boost::mutex m_mutex;
      sometype*  m_myVar;
  }
  
  A::methodA( int someParam )
  {
      boost::mutex::scoped_lock myLock(m_mutex);
      m_myVar-&gt;doSomethingElse();
  }
  
  A::methodB( int someParam )
  {
      boost::mutex::scoped_lock myLock(m_mutex);
      m_myVar-&gt;doSomething();
      this-&gt;methodA(someParam);
  }
  </code></pre>
  
  <p>I would like to synchronize access on <code>m_myVar</code>. When calling <code>A::methodB()</code>, the thread runs into the lock with the same mutex twice and obviously blocks on the first line of <code>A::methodA()</code></p>
  
  <p>Is there any way to make <code>scoped_lock</code> not blocking the <strong>same thread</strong> when passing again?</p>
  
  <p>Sure, I simply could call <code>m_mutex.unlock()</code>. But this would free the other threads waiting on the lock as well - which is absolutely not what I want.</p>
  
  <p>Any idea?</p>
  
  <p>Best regards
  Tobias</p>