mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-18 13:42:02 +00:00
28 lines
360 B
C++
28 lines
360 B
C++
#pragma once
|
|
|
|
namespace ext
|
|
{
|
|
|
|
template <typename T>
|
|
class unlock_guard
|
|
{
|
|
public:
|
|
unlock_guard(T & mutex_) : mutex(mutex_)
|
|
{
|
|
mutex.unlock();
|
|
}
|
|
|
|
~unlock_guard()
|
|
{
|
|
mutex.lock();
|
|
}
|
|
|
|
unlock_guard(const unlock_guard &) = delete;
|
|
unlock_guard & operator=(const unlock_guard &) = delete;
|
|
|
|
private:
|
|
T & mutex;
|
|
};
|
|
|
|
}
|