From 33cb41edcb572eac2be53d7f025ddf8096fab15c Mon Sep 17 00:00:00 2001 From: Muhammad Zahalqa Date: Fri, 14 Aug 2020 17:06:02 +0300 Subject: [PATCH] LibThread: Lockable - add forwarding constructor --- Libraries/LibThread/Lock.h | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/Libraries/LibThread/Lock.h b/Libraries/LibThread/Lock.h index b6a82c42a2..7ab63162c7 100644 --- a/Libraries/LibThread/Lock.h +++ b/Libraries/LibThread/Lock.h @@ -28,17 +28,17 @@ #ifdef __serenity__ -#include -#include -#include -#include +# include +# include +# include +# include namespace LibThread { class Lock { public: - Lock() {} - ~Lock() {} + Lock() { } + ~Lock() { } void lock(); void unlock(); @@ -90,12 +90,19 @@ inline void Lock::unlock() --m_level; } -#define LOCKER(lock) LibThread::Locker locker(lock) +# define LOCKER(lock) LibThread::Locker locker(lock) template class Lockable { public: - Lockable() {} + Lockable() { } + + template + Lockable(Args&&... args) + : m_resource(forward(args)...) + { + } + Lockable(T&& resource) : m_resource(move(resource)) { @@ -128,6 +135,6 @@ public: } -#define LOCKER(x) +# define LOCKER(x) #endif