From dabb3c902abf8a9ed4676e6466ab6b9198f5ac5a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 8 Feb 2019 09:46:13 +0100 Subject: AK: Add a Lockable wrapping container. --- AK/Lock.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/AK/Lock.h b/AK/Lock.h index 50d5336c28..cc9bc5ff1a 100644 --- a/AK/Lock.h +++ b/AK/Lock.h @@ -95,7 +95,21 @@ inline void Lock::unlock() #define LOCKER(lock) Locker locker(lock) +template +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; -- cgit v1.2.3