mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-27 15:53:13 +08:00
unit_test/preamble/preamble_fixture.h -> common/fixtures unit_test/source_level_debugger -> common/ unit_test/utilities/base_object_utils.h -> common/utilities unit_test/utilities/destructor_counted.h -> common/utilities unit_test/utilities/logger_tests.h -> common/utilities Related-To: NEO-6524 Signed-off-by: Warchulski, Jaroslaw <jaroslaw.warchulski@intel.com>
35 lines
710 B
C++
35 lines
710 B
C++
/*
|
|
* Copyright (C) 2018-2022 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
#include <memory>
|
|
|
|
namespace NEO {
|
|
|
|
template <typename T>
|
|
struct ReleaseObject {
|
|
void operator()(T *t) {
|
|
if (t != nullptr) {
|
|
t->release();
|
|
}
|
|
}
|
|
};
|
|
|
|
template <typename T>
|
|
using ReleaseableObjectPtr = std::unique_ptr<T, ReleaseObject<T>>;
|
|
|
|
template <typename T>
|
|
static ReleaseableObjectPtr<T> clUniquePtr(T *object) {
|
|
return ReleaseableObjectPtr<T>{object};
|
|
}
|
|
|
|
template <class _Ty, class... _Types>
|
|
inline ReleaseableObjectPtr<_Ty> makeReleaseable(_Types &&...args) {
|
|
return (ReleaseableObjectPtr<_Ty>(new _Ty(std::forward<_Types>(args)...)));
|
|
}
|
|
} // namespace NEO
|