Skip to content

Commit 686da9f

Browse files
committed
Fix template args
1 parent 7e46e9f commit 686da9f

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/cpp/notify-helper.hpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ class NotifyHelper {
99
public:
1010
NotifyHelper(Napi::Function callback, Napi::Value userData) {
1111
Napi::Env env = callback.Env();
12-
_tsfn = Napi::ThreadSafeFunction::New(
13-
env, callback, Napi::Object(), "NotifyHelper", 0, 1, _delete
14-
);
1512

1613
_ref.Reset(Napi::Object::New(env), 1);
1714
_ref.Set("cb", callback);
1815
_ref.Set("data", userData);
16+
17+
void *context = nullptr;
18+
_tsfn = Napi::ThreadSafeFunction::New(
19+
env, callback, _ref.Value(), "NotifyHelper", 0LLU, 1LLU, context, _delete, this
20+
);
1921
}
2022

2123
~NotifyHelper() {
@@ -26,27 +28,24 @@ class NotifyHelper {
2628
}
2729

2830
static void CL_CALLBACK callNotify(T resource, void *ptr) {
29-
NotifyHelper *notifier = reinterpret_cast<NotifyHelper*>(ptr);
31+
NotifyHelper<T> *notifier = reinterpret_cast<NotifyHelper<T>*>(ptr);
3032
notifier->_notify(resource);
3133
}
3234
static void CL_CALLBACK callNotifyStatus(T resource, cl_int status, void *ptr) {
33-
NotifyHelper *notifier = reinterpret_cast<NotifyHelper*>(ptr);
35+
NotifyHelper<T> *notifier = reinterpret_cast<NotifyHelper<T>*>(ptr);
3436
notifier->_notifyStatus(resource, status);
3537
}
3638

3739
private:
3840
Napi::ObjectReference _ref;
3941
Napi::ThreadSafeFunction _tsfn;
4042

41-
static void _delete(napi_env env, void* data, void*) {
42-
if (data != nullptr) {
43-
NotifyHelper* that = static_cast<NotifyHelper*>(data);
44-
delete that;
45-
}
43+
static void _delete(napi_env env, NotifyHelper<T>* that, void*) {
44+
delete that;
4645
}
4746

4847
void _notify(T resource) {
49-
NotifyHelper *that = this;
48+
NotifyHelper<T> *that = this;
5049
napi_status result = _tsfn.NonBlockingCall(
5150
[that, resource](Napi::Env env, Napi::Function callback) {
5251
callback.Call(
@@ -63,7 +62,7 @@ class NotifyHelper {
6362
}
6463

6564
void _notifyStatus(T resource, cl_int status) {
66-
NotifyHelper *that = this;
65+
NotifyHelper<T> *that = this;
6766
napi_status result = _tsfn.NonBlockingCall(
6867
[that, resource, status](Napi::Env env, Napi::Function callback) {
6968
callback.Call(

0 commit comments

Comments
 (0)