mirror of
https://github.com/matrix-construct/construct
synced 2025-02-18 01:30:12 +01:00
ircd::util: Add an unlock_guard.
This commit is contained in:
parent
6dfe034f6f
commit
90f9c0e39d
1 changed files with 18 additions and 0 deletions
|
@ -1116,5 +1116,23 @@ ctype(const char *begin,
|
|||
}
|
||||
|
||||
|
||||
template<class lockable>
|
||||
struct unlock_guard
|
||||
{
|
||||
lockable &l;
|
||||
|
||||
unlock_guard(lockable &l)
|
||||
:l{l}
|
||||
{
|
||||
l.unlock();
|
||||
}
|
||||
|
||||
~unlock_guard() noexcept
|
||||
{
|
||||
l.lock();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace util
|
||||
} // namespace ircd
|
||||
|
|
Loading…
Add table
Reference in a new issue