From 4809dc8ec28b8573b250a112b9a7dae4cde10e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Thu, 18 Aug 2022 21:44:31 +0200 Subject: [PATCH] AK: Add Singleton special-case constructor for SpinlockProtected This will allow Singletons of that class to still be created when SpinlockProtected can't be constructed without a lock rank argument anymore. --- AK/Singleton.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/AK/Singleton.h b/AK/Singleton.h index 3e67dea1304..a0c6fa32902 100644 --- a/AK/Singleton.h +++ b/AK/Singleton.h @@ -12,6 +12,7 @@ #ifdef KERNEL # include # include +# include #else # include #endif @@ -30,6 +31,18 @@ struct SingletonInstanceCreator { } }; +#ifdef KERNEL + +// FIXME: Find a nice way of injecting the lock rank into the singleton. +template +struct SingletonInstanceCreator> { + static Kernel::SpinlockProtected* create() + { + return new Kernel::SpinlockProtected { Kernel::LockRank::None }; + } +}; +#endif + template::create> class Singleton { AK_MAKE_NONCOPYABLE(Singleton);