/* * ======================================================== * * hCore * Copyright Mahrouss Logic, all rights reserved. * * ======================================================== */ //! @brief Allocates a pointer from the process's tls. template inline T* hcore_tls_new_ptr(void) { using namespace hCore; auto ref_process = ProcessManager::Shared().Leak().GetCurrent(); T* pointer = (T*)ref_process.Leak().New(sizeof(T)); return pointer; } //! @brief TLS delete implementation. template inline bool hcore_tls_delete_ptr(T* ptr) { if (!ptr) return false; using namespace hCore; auto ref_process = ProcessManager::Shared().Leak().GetCurrent(); ptr->~T(); return ref_process.Leak().Delete(ptr, sizeof(T)); } template T* hcore_tls_new_class(Args&&... args) { T* ptr = hcore_tls_new_ptr(); if (ptr) { *ptr = T(hCore::forward(args)...); return ptr; } return nullptr; }