@ 260528.1

260407.1 · bfb184f7eaad40dedc6736445d6490b2a690927a

Pin dependencies (#621)

reading declarations

Changes to src/6-threadsafe-function/thread_safe_function_with_object_wrap/node-addon-api/. All files

src/6-threadsafe-function/thread_safe_function_with_object_wrap/node-addon-api/package.json

@@ -2,7 +2,7 @@   "name": "tsfn-test",   "version": "1.0.0",   "description": "",-  "main": "index.js",+  "main": "tsfn_object_wrap.js",   "author": "",   "dependencies": {     "bindings": "*",

src/6-threadsafe-function/thread_safe_function_with_object_wrap/node-addon-api/tsfn_object_wrap.cc

@@ -24,7 +24,6 @@ class TsfnObjectWrap : public Napi::ObjectWrap<TsfnObjectWrap> {   }    ~TsfnObjectWrap() {-    _tsfn.Abort();     _thread.join();   } @@ -44,7 +43,7 @@ class TsfnObjectWrap : public Napi::ObjectWrap<TsfnObjectWrap> {       idx = (idx + 1) % 3;       int64_t* value_ref = &buffer[idx];       napi_status status = tsfn.BlockingCall(-          value_ref, [](Napi::Env env, Napi::Function fn, int64_t* data) {+          value_ref, [tsfn](Napi::Env env, Napi::Function fn, int64_t* data) {             int64_t native_value = *data;             Napi::Value result =                 fn.Call({Napi::Number::New(env, native_value)});@@ -55,6 +54,9 @@ class TsfnObjectWrap : public Napi::ObjectWrap<TsfnObjectWrap> {               printf("main with %" PRId64 ": Done!\n",                      result.As<Napi::Number>().Int64Value());             }+            if (native_value == 10) {+              tsfn.Abort();+            }           });       // We break out of the infinite loop when we're informed that the thread-       // safe function is being torn down.