@@ -9,17 +9,17 @@ using namespace Napi;
9
9
namespace call {
10
10
11
11
// Context of the TSFN.
12
- using Context = std::nullptr_t ;
12
+ using ContextType = std::nullptr_t ;
13
13
14
14
// Data passed (as pointer) to [Non]BlockingCall
15
- struct Data {
15
+ struct DataType {
16
16
Reference<Napi::Value> data;
17
17
Promise::Deferred deferred;
18
18
};
19
19
20
20
// CallJs callback function
21
21
static void CallJs (Napi::Env env, Napi::Function jsCallback,
22
- Context * /* context*/ , Data *data) {
22
+ ContextType * /* context*/ , DataType *data) {
23
23
if (!(env == nullptr || jsCallback == nullptr )) {
24
24
if (data != nullptr ) {
25
25
jsCallback.Call (env.Undefined (), {data->data .Value ()});
@@ -32,10 +32,10 @@ static void CallJs(Napi::Env env, Napi::Function jsCallback,
32
32
}
33
33
34
34
// Full type of the ThreadSafeFunctionEx
35
- using TSFN = ThreadSafeFunctionEx<Context, Data , CallJs>;
35
+ using TSFN = ThreadSafeFunctionEx<ContextType, DataType , CallJs>;
36
36
37
37
class TSFNWrap ;
38
- using base = tsfnutil::TSFNWrapBase<TSFNWrap, Context , TSFN>;
38
+ using base = tsfnutil::TSFNWrapBase<TSFNWrap, ContextType , TSFN>;
39
39
40
40
// A JS-accessible wrap that holds the TSFN.
41
41
class TSFNWrap : public base {
@@ -49,7 +49,7 @@ class TSFNWrap : public base {
49
49
1 , // size_t initialThreadCount,
50
50
nullptr , // ContextType* context
51
51
base::Finalizer, // Finalizer finalizer
52
- &_deferred // FinalizerDataType data
52
+ &_deferred // FinalizerDataType* data
53
53
);
54
54
}
55
55
@@ -60,7 +60,7 @@ class TSFNWrap : public base {
60
60
61
61
Napi::Value Call (const CallbackInfo &info) {
62
62
Napi::Env env = info.Env ();
63
- Data *data = new Data {Napi::Reference<Napi::Value>(Persistent (info[0 ])),
63
+ DataType *data = new DataType {Napi::Reference<Napi::Value>(Persistent (info[0 ])),
64
64
Promise::Deferred::New (env)};
65
65
_tsfn.NonBlockingCall (data);
66
66
return data->deferred .Promise ();
@@ -73,14 +73,14 @@ class TSFNWrap : public base {
73
73
namespace context {
74
74
75
75
// Context of the TSFN.
76
- using Context = Reference<Napi::Value>;
76
+ using ContextType = Reference<Napi::Value>;
77
77
78
78
// Data passed (as pointer) to [Non]BlockingCall
79
- using Data = Promise::Deferred;
79
+ using DataType = Promise::Deferred;
80
80
81
81
// CallJs callback function
82
82
static void CallJs (Napi::Env env, Napi::Function /* jsCallback*/ ,
83
- Context *context, Data *data) {
83
+ ContextType *context, DataType *data) {
84
84
if (env != nullptr ) {
85
85
if (data != nullptr ) {
86
86
data->Resolve (context->Value ());
@@ -92,18 +92,18 @@ static void CallJs(Napi::Env env, Napi::Function /*jsCallback*/,
92
92
}
93
93
94
94
// Full type of the ThreadSafeFunctionEx
95
- using TSFN = ThreadSafeFunctionEx<Context, Data , CallJs>;
95
+ using TSFN = ThreadSafeFunctionEx<ContextType, DataType , CallJs>;
96
96
97
97
class TSFNWrap ;
98
- using base = tsfnutil::TSFNWrapBase<TSFNWrap, Context , TSFN>;
98
+ using base = tsfnutil::TSFNWrapBase<TSFNWrap, ContextType , TSFN>;
99
99
100
100
// A JS-accessible wrap that holds the TSFN.
101
101
class TSFNWrap : public base {
102
102
public:
103
103
TSFNWrap (const CallbackInfo &info) : base(info) {
104
104
Napi::Env env = info.Env ();
105
105
106
- Context *context = new Context (Persistent (info[0 ]));
106
+ ContextType *context = new ContextType (Persistent (info[0 ]));
107
107
108
108
_tsfn = TSFN::New (
109
109
env, // napi_env env,
@@ -112,9 +112,9 @@ class TSFNWrap : public base {
112
112
" Test" , // ResourceString resourceName,
113
113
0 , // size_t maxQueueSize,
114
114
1 , // size_t initialThreadCount,
115
- context, // Context * context,
115
+ context, // ContextType * context,
116
116
base::Finalizer, // Finalizer finalizer
117
- &_deferred // FinalizerDataType data
117
+ &_deferred // FinalizerDataType* data
118
118
);
119
119
}
120
120
@@ -125,7 +125,7 @@ class TSFNWrap : public base {
125
125
}
126
126
127
127
Napi::Value Call (const CallbackInfo &info) {
128
- auto *callData = new Data (info.Env ());
128
+ auto *callData = new DataType (info.Env ());
129
129
_tsfn.NonBlockingCall (callData);
130
130
return callData->Promise ();
131
131
};
@@ -140,17 +140,17 @@ namespace empty {
140
140
#if NAPI_VERSION > 4
141
141
142
142
// Context of the TSFN.
143
- using Context = std::nullptr_t ;
143
+ using ContextType = std::nullptr_t ;
144
144
145
145
// Data passed (as pointer) to [Non]BlockingCall
146
- struct Data {
146
+ struct DataType {
147
147
Promise::Deferred deferred;
148
148
bool reject;
149
149
};
150
150
151
151
// CallJs callback function
152
- static void CallJs (Napi::Env env, Function jsCallback, Context * /* context*/ ,
153
- Data *data) {
152
+ static void CallJs (Napi::Env env, Function jsCallback, ContextType * /* context*/ ,
153
+ DataType *data) {
154
154
if (env != nullptr ) {
155
155
if (data != nullptr ) {
156
156
if (data->reject ) {
@@ -166,10 +166,10 @@ static void CallJs(Napi::Env env, Function jsCallback, Context * /*context*/,
166
166
}
167
167
168
168
// Full type of the ThreadSafeFunctionEx
169
- using TSFN = ThreadSafeFunctionEx<Context, Data , CallJs>;
169
+ using TSFN = ThreadSafeFunctionEx<ContextType, DataType , CallJs>;
170
170
171
171
class TSFNWrap ;
172
- using base = tsfnutil::TSFNWrapBase<TSFNWrap, Context , TSFN>;
172
+ using base = tsfnutil::TSFNWrapBase<TSFNWrap, ContextType , TSFN>;
173
173
174
174
// A JS-accessible wrap that holds the TSFN.
175
175
class TSFNWrap : public base {
@@ -183,7 +183,7 @@ class TSFNWrap : public base {
183
183
1 , // size_t initialThreadCount,
184
184
nullptr , // ContextType* context
185
185
base::Finalizer, // Finalizer finalizer
186
- &_deferred // FinalizerDataType data
186
+ &_deferred // FinalizerDataType* data
187
187
);
188
188
}
189
189
@@ -200,7 +200,7 @@ class TSFNWrap : public base {
200
200
}
201
201
202
202
auto *data =
203
- new Data {Promise::Deferred::New (info.Env ()), info[0 ].ToBoolean ()};
203
+ new DataType {Promise::Deferred::New (info.Env ()), info[0 ].ToBoolean ()};
204
204
_tsfn.NonBlockingCall (data);
205
205
return data->deferred .Promise ();
206
206
};
@@ -212,7 +212,7 @@ class TSFNWrap : public base {
212
212
namespace existing {
213
213
214
214
// Data passed (as pointer) to [Non]BlockingCall
215
- struct Data {
215
+ struct DataType {
216
216
Promise::Deferred deferred;
217
217
bool reject;
218
218
};
@@ -222,7 +222,7 @@ struct Data {
222
222
// are napi_*.
223
223
static void CallJs (napi_env env, napi_value jsCallback, void * /* context*/ ,
224
224
void *data) {
225
- Data *casted = static_cast <Data *>(data);
225
+ DataType *casted = static_cast <DataType *>(data);
226
226
if (env != nullptr ) {
227
227
if (data != nullptr ) {
228
228
napi_value undefined;
@@ -244,16 +244,16 @@ static void CallJs(napi_env env, napi_value jsCallback, void * /*context*/,
244
244
// parameter is the `TSFNWrap` object. We forward-declare, so we can use
245
245
// it as an argument inside `ThreadSafeFunctionEx<>`. This also allows us to
246
246
// statically get the correct type when using `tsfn.GetContext()`. The converse
247
- // is true: if the Context type does _not_ match that provided to the underlying
247
+ // is true: if the ContextType does _not_ match that provided to the underlying
248
248
// napi_create_threadsafe_function, then the static type will be incorrect.
249
249
class TSFNWrap ;
250
250
251
251
// Context of the TSFN.
252
- using Context = TSFNWrap;
252
+ using ContextType = TSFNWrap;
253
253
254
254
// Full type of our ThreadSafeFunctionEx
255
- using TSFN = ThreadSafeFunctionEx<Context, Data >;
256
- using base = tsfnutil::TSFNWrapBase<TSFNWrap, Context , TSFN>;
255
+ using TSFN = ThreadSafeFunctionEx<ContextType, DataType >;
256
+ using base = tsfnutil::TSFNWrapBase<TSFNWrap, ContextType , TSFN>;
257
257
258
258
// A JS-accessible wrap that holds a TSFN.
259
259
class TSFNWrap : public base {
@@ -297,7 +297,7 @@ class TSFNWrap : public base {
297
297
298
298
Napi::Value Call (const CallbackInfo &info) {
299
299
auto *data =
300
- new Data {Promise::Deferred::New (info.Env ()), info[0 ].ToBoolean ()};
300
+ new DataType {Promise::Deferred::New (info.Env ()), info[0 ].ToBoolean ()};
301
301
_tsfn.NonBlockingCall (data);
302
302
return data->deferred .Promise ();
303
303
};
@@ -321,15 +321,15 @@ class TSFNWrap : public base {
321
321
} // namespace existing
322
322
namespace simple {
323
323
324
- using Context = std::nullptr_t ;
324
+ using ContextType = std::nullptr_t ;
325
325
326
- // Full type of our ThreadSafeFunctionEx. We don't specify the `Context ` here
326
+ // Full type of our ThreadSafeFunctionEx. We don't specify the `ContextType ` here
327
327
// (even though the _default_ for the type argument is `std::nullptr_t`) to
328
328
// demonstrate construction with no type arguments.
329
329
using TSFN = ThreadSafeFunctionEx<>;
330
330
331
331
class TSFNWrap ;
332
- using base = tsfnutil::TSFNWrapBase<TSFNWrap, Context , TSFN>;
332
+ using base = tsfnutil::TSFNWrapBase<TSFNWrap, ContextType , TSFN>;
333
333
334
334
// A JS-accessible wrap that holds a TSFN.
335
335
class TSFNWrap : public base {
0 commit comments