mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-07 12:42:54 +08:00
refactor: Common ext pattern in KernelExecutionEnv
Signed-off-by: Chodor, Jaroslaw <jaroslaw.chodor@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
b44d8c9b87
commit
ad78ea7da4
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user