Files
compute-runtime/opencl/source/helpers/destructor_callback.h
Filip Hazubski d889c599b2 Correct callback API functions
Add implementation to clSetProgramReleaseCallback and
clSetContextDestructorCallback functions.

Resolves: NEO-4962, NEO-5051

Change-Id: Iad6fffc663665a3cf16b96aa90065140cf8c5477
Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
2020-09-08 14:08:50 +02:00

34 lines
733 B
C++

/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "CL/cl.h"
namespace NEO {
template <typename T>
class DestructorCallback {
public:
DestructorCallback(void(CL_CALLBACK *funcNotify)(T, void *),
void *userData)
: funcNotify(funcNotify), userData(userData){};
inline void invoke(T object) {
this->funcNotify(object, userData);
}
private:
void(CL_CALLBACK *funcNotify)(T, void *);
void *userData;
};
using ContextDestructorCallback = DestructorCallback<cl_context>;
using MemObjDestructorCallback = DestructorCallback<cl_mem>;
using ProgramReleaseCallback = DestructorCallback<cl_program>;
} // namespace NEO