title: mutexes and locks
body: <p>Are the two code samples below equivalent?</p>
  
  <pre><code>Poco::ProcessHandle::PID ProcessRunner::processId() const
  {
      Poco::ProcessHandle::PID pid = 0;
      mMutex.lock();
      pid = mPID;
      mMutex.unlock();
      return pid;
  }
  </code></pre>
  
  <p>,</p>
  
  <pre><code>Poco::ProcessHandle::PID ProcessRunner::processId() const
  {
      Poco::ScopedLock&lt;Poco::Mutex&gt; lock(mMutex);
      return mPID;
  }
  </code></pre>
  
  <ul>
  <li>In the second sample: will the lock go out of scope after the return value copy has been made? This would matter if an object was returned that had many instructions for copying.</li>
  <li>Is a lock necessary if you are only going to return an int value? Or is the copying of the int an atomic operation?</li>
  </ul>