summaryrefslogtreecommitdiffhomepage
path: root/Kernel/KernelKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-05-12 14:22:35 +0200
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-05-12 14:22:35 +0200
commitc90f6b27e5fe229a69a20f4a4fc453bb6e787e90 (patch)
treebf740a60a65d5e33d7e4ee64a0837599f7e99771 /Kernel/KernelKit
parent4e4f9e871236067f0cda4b67a732d3b3bbf08884 (diff)
MHR-23: Add tls_delete_class function.
Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
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