summaryrefslogtreecommitdiffhomepage
path: root/Kernel/KernelKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-05-12 22:53:07 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-05-12 22:53:07 +0200
commit23cd8f6c24582add8fdd4f44517a4ce7b4ffc183 (patch)
treedf4408068f59e1b427c519c57ec30f589c466deb /Kernel/KernelKit
parent9d8b704783b94ed3ee4cd87f87e54eb1808d7db8 (diff)
parentc90f6b27e5fe229a69a20f4a4fc453bb6e787e90 (diff)
Merge branch 'MHR-23' of bitbucket.org:mahrouss/microkernel into MHR-23
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