diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-02-08 09:46:13 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-02-08 09:46:13 +0100 |
commit | dabb3c902abf8a9ed4676e6466ab6b9198f5ac5a (patch) | |
tree | 733d2ff01ed8aa29d4f0872743e9a9859bed9d9b | |
parent | 7e623e7ff2a139e1d04e02efd6437b24c88a7e97 (diff) | |
download | serenity-dabb3c902abf8a9ed4676e6466ab6b9198f5ac5a.zip |
AK: Add a Lockable wrapping container.
-rw-r--r-- | AK/Lock.h | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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; |