mutex.lock vs unique_lock
<p>When should I prefer the first piece of code to the second, and do they have fundamental differences</p>

<pre><code>std::mutex mtx;
mtx.lock();
... //protected stuff
mtx.unlock();
... //non-protected stuff
mtx.lock();
... //etc
</code></pre>

<p>and</p>

<pre><code>std::mutex mtx;
std::unique_lock&lt;std::mutex&gt; lck(mtx);
... //protected stuff
lck.unlock();
... //non-protected stuff
lck.lock();
... //etc
</code></pre>

<p>I do understand that lock_guard is basically a unique_lock without the lock and unlock functions, but I'm having hard time differentiating a mutex and a lock using a mutex. </p>