-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ThreadSafeFunction(napi_threadsafe_function) works badly with BlockingCall() #556
Comments
Hello @o2genum , Can you post some code that you are using? Here's some code using BlockingCall() in all three overloads: node-addon-api/test/threadsafe_function/threadsafe_function.cc Lines 52 to 66 in dd9fa8a
We have two tests: one using node-addon-api/test/threadsafe_function/threadsafe_function_sum.cc Lines 35 to 41 in e10e683
And here we use |
Ahh, I am sorry, I misunderstood your issue. Using the node-addon-api with a pre-constructed |
Nice! By the way, I want to note I could have done without wrapping TSFN from C API into C++ API one if there was a way to call |
Hi @o2genum , Yeah, so I'm not sure how we can wrap an existing When creating a node-addon-api I'll need to discuss this with the napi team for a good approach / if it's even possible. In the mean time, we have two PRs that can solve your problem:
|
Hi @gabrielschulhof / @mhdawson , I wanted to bring this up at yesterday's meeting but alas... To address this issue, I can think of two ways but both work off this general paradigm:
Now I say "two" ways because: Edit: option 1 is not feasible |
As discussed in 21-Oct meeting: The other existing |
Ref: #556 (comment) PR-URL: #561 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Ref: nodejs/node-addon-api#556 (comment) PR-URL: nodejs/node-addon-api#561 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
support direct calls to underlying napi_tsfn Fixes: nodejs/node-addon-api#556 PR-URL: nodejs/node-addon-api#58 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Ref: nodejs/node-addon-api#556 (comment) PR-URL: nodejs/node-addon-api#561 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
support direct calls to underlying napi_tsfn Fixes: nodejs/node-addon-api#556 PR-URL: nodejs/node-addon-api#58 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Ref: nodejs/node-addon-api#556 (comment) PR-URL: nodejs/node-addon-api#561 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
support direct calls to underlying napi_tsfn Fixes: nodejs/node-addon-api#556 PR-URL: nodejs/node-addon-api#58 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Ref: nodejs/node-addon-api#556 (comment) PR-URL: nodejs/node-addon-api#561 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
support direct calls to underlying napi_tsfn Fixes: nodejs/node-addon-api#556 PR-URL: nodejs/node-addon-api#58 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
When a
ThreadSafeFunction
instance is created fromnapi_threadsafe_function
, itsBlockingCall
method doesn't work properly:napi_create_threadsafe_function
is used)data
pointer is incorrect for some reason.napi_call_threadsafe_function
works fine.I'm doing this because I want to
napi_unref_threadsafe_function
without using all the verbose C APIs.The text was updated successfully, but these errors were encountered: