---
title: "unique_lock"
source: https://www.jemoka.com/posts/kbhunique_lock/
---

the unique_lock is a mutex management type. Its a lock management system whereby the type will unlock the mutex on your behalf whenever the unique lock goes out of scope.
this is useful if there are multiple paths to exit a function, where an edge case made you forget when to unlock:
void my_scope(mutex &amp;mut, condition_variable_any &amp;cv) { unique_lock&lt;mutex&gt; lck(mut); // do stuff, you can even pass it to a condition variable! cv.wait(lck); }
