refactor: Common ext pattern in KernelExecutionEnv

Signed-off-by: Chodor, Jaroslaw <jaroslaw.chodor@intel.com>
This commit is contained in:
Chodor, Jaroslaw
2025-07-25 13:50:40 +00:00
committed by Compute-Runtime-Automation
parent b44d8c9b87
commit ad78ea7da4
4 changed files with 22 additions and 20 deletions

View File

@@ -15,6 +15,9 @@ using ExtUniquePtrT = std::unique_ptr<T, void (*)(T *)>;
template <typename T>
void cloneExt(ExtUniquePtrT<T> &dst, const T &src);
template <typename T>
void allocateExt(ExtUniquePtrT<T> &dst);
template <typename T>
void destroyExt(T *dst);
@@ -51,10 +54,14 @@ struct UniquePtrWrapperOps {
} // namespace Impl
template <typename T>
template <typename T, bool allocateAtInit = false>
struct Ext : Impl::UniquePtrWrapperOps<Ext<T>> {
Ext(T *ptr) : ptr(ptr, destroyExt) {}
Ext() = default;
Ext() {
if constexpr (allocateAtInit) {
allocateExt(ptr);
}
}
Ext(const Ext &rhs) {
if (rhs.ptr.get()) {
cloneExt(this->ptr, *rhs.ptr.get());