Commit eca6b9f0 authored by Max Kellermann's avatar Max Kellermann

thread/Mutex: add method ScopeLock::Unlock()

parent cc9345e7
......@@ -45,17 +45,25 @@ class Mutex : public PosixMutex {};
class ScopeLock {
Mutex &mutex;
bool active = true;
public:
ScopeLock(Mutex &_mutex):mutex(_mutex) {
mutex.lock();
};
~ScopeLock() {
mutex.unlock();
if (active)
mutex.unlock();
};
ScopeLock(const ScopeLock &other) = delete;
ScopeLock &operator=(const ScopeLock &other) = delete;
void Unlock() {
mutex.unlock();
active = false;
}
};
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment