AK: Add a Lockable wrapping container.

This commit is contained in:
Andreas Kling 2019-02-08 09:46:13 +01:00
parent 7e623e7ff2
commit dabb3c902a
Notes: sideshowbarker 2024-07-19 15:49:44 +09:00

View file

@ -95,7 +95,21 @@ inline void Lock::unlock()
#define LOCKER(lock) Locker locker(lock)
template<typename T>
class Lockable {
public:
Lockable() { }
Lockable(T&& resource) : m_resource(move(resource)) { }
Lock& lock() { return m_lock; }
T& resource() { return m_resource; }
private:
T m_resource;
Lock m_lock;
};
}
using AK::Lock;
using AK::Locker;
using AK::Lockable;