My final goal is to solve this problem, but I am getting stuck on some pretty basic stuff.
My whole C++ Module is basically as follows:
void AsyncWork(void *arg) {
Isolate* isolate = Isolate::GetCurrent(); // isolate is NULL
if (isolate != NULL) {
HandleScope scope(isolate);
}
else {
printf("isolate is null\n");
return;
}
// ...
}
void testAsync(const FunctionCallbackInfo<Value>& args) {
uv_thread_t id;
int data = 10;
uv_thread_create(&id, AsyncWork, &data);
}
void init(Handle<Object> target) {
NODE_SET_METHOD(target, "testAsync", testAsync);
}
NODE_MODULE(MyCppModule, init);
Why is isolate
NULL after I call Isolate::GetCurrent()
in AsyncWork?