summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-02-08 09:46:13 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-02-08 09:46:13 +0100
commitdabb3c902abf8a9ed4676e6466ab6b9198f5ac5a (patch)
tree733d2ff01ed8aa29d4f0872743e9a9859bed9d9b
parent7e623e7ff2a139e1d04e02efd6437b24c88a7e97 (diff)
downloadserenity-dabb3c902abf8a9ed4676e6466ab6b9198f5ac5a.zip
AK: Add a Lockable wrapping container.
-rw-r--r--AK/Lock.h14
1 files changed, 14 insertions, 0 deletions
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<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;