summaryrefslogtreecommitdiffhomepage
path: root/Kernel/KernelKit
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/KernelKit')
-rw-r--r--Kernel/KernelKit/ThreadLocalStorage.inl20
1 files changed, 17 insertions, 3 deletions
diff --git a/Kernel/KernelKit/ThreadLocalStorage.inl b/Kernel/KernelKit/ThreadLocalStorage.inl
index ae3277eb..6407900f 100644
--- a/Kernel/KernelKit/ThreadLocalStorage.inl
+++ b/Kernel/KernelKit/ThreadLocalStorage.inl
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright SoftwareLabs
------------------------------------------- */
@@ -34,12 +34,15 @@ inline bool tls_delete_ptr(T* ptr)
MUST_PASS(ProcessScheduler::Shared().Leak().GetCurrent());
- ptr->~T();
-
auto ref_process = ProcessScheduler::Shared().Leak().GetCurrent();
return ref_process.Leak().Delete(ptr, sizeof(T));
}
+/// @brief Allocate a C++ class, and then call the constructor of it.
+/// @tparam T
+/// @tparam ...Args
+/// @param ...args
+/// @return
template <typename T, typename... Args>
T* tls_new_class(Args&&... args)
{
@@ -53,3 +56,14 @@ T* tls_new_class(Args&&... args)
return nullptr;
}
+
+/// @brief Delete a C++ class (call constructor first.)
+/// @tparam T
+/// @param ptr
+/// @return
+template <typename T>
+inline bool tls_delete_class(T* ptr)
+{
+ ptr->~T();
+ return tls_delete_ptr(ptr);
+} \ No newline at end of file