Skip to content
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

Support for Asynchronous Thread-safe Function Calls #312

Closed
srirajpaul opened this issue Jul 30, 2018 · 15 comments
Closed

Support for Asynchronous Thread-safe Function Calls #312

srirajpaul opened this issue Jul 30, 2018 · 15 comments

Comments

@srirajpaul
Copy link

Hello, Thank you for the effort to create and maintain the C++ wrappers for N-API. The wrappers make it very much easier to create native addons.

N-API added capability for additional threads to invoke JavaScript functions based on the processing completed by those threads. Is there any timeline/plan to add wrappers for the same?

https://nodejs.org/docs/latest-v10.x/api/n-api.html#n_api_asynchronous_thread_safe_function_calls

Thank you

@romandev
Copy link
Contributor

romandev commented Jul 30, 2018

I'll take this issue if there is no one actively working on this.

@atoy40
Copy link

atoy40 commented Dec 11, 2018

Hello,
any news on this one ? I've discovered this project https://github.com/mika-fischer/napi-thread-safe-callback, it seems to have the same goal but use libuv directly to achieve it.

@romandev
Copy link
Contributor

Ah, I missed this.. I'm on a trip now. I'll finish to implement this until next week.

@aazavid
Copy link

aazavid commented Jan 22, 2019

How is the process going? It would be nice to get examples.

@romandev
Copy link
Contributor

I tried to work on this issue for a while after a long vacation, but soon @DaAitch PR(#424) came up. I was too late and his PR looks reasonable to me. I believe he will finish the work soon. :)

@DaAitch
Copy link
Contributor

DaAitch commented Jan 24, 2019

@romandev I tought you're working on wrapping napi_threadsafe_function calls? I did not do that. I was working on a util method for making node calls from second thread easier.

@romandev
Copy link
Contributor

@DaAitch Okay, thank you for explanation. I was lacking in understanding. I'll send a PR. Please review it when you have a spare time.

@DaAitch
Copy link
Contributor

DaAitch commented Jan 29, 2019

@romandev @mhdawson @gabrielschulhof

I think this needs some clarification now. Also in last Team meeting it was said, that I'm working on this which is not correct 😁 .

There is misunderstanding happening here. @romandev started working on a PR to land napi tsfn node-addon-api impl. I did not do that. I was working on an idea I started as WIP PR (#424), but which might never land. Only for the purpose to have some kind of documentation on things we tried out.

The reason why it looks like I did the tsfn implemention for node-addon-api is simply because the Napi::ThreadSafeFunction impl is missing and I need to use napi tsfn, so my "util" class uses napi tsfn directly. When the PR for this issues has landed, I can rewrite it.

So @romandev please go ahead with your PR on this. I think it would be good to land this soon because I'm also thinking that tsfn is a killer feature, so if you need help or want to hand it over please raise your hand.

romandev added a commit to romandev/node-addon-api that referenced this issue Feb 5, 2019
This PR is implementing ThreadSafeFunction class wraps
napi_threadsafe_function*.

Fixes nodejs#312.
romandev added a commit to romandev/node-addon-api that referenced this issue Mar 6, 2019
This PR is implementing ThreadSafeFunction class wraps
napi_threadsafe_function features.

FYI, the test files that included in this PR have come from Node.js
repo[1]. They've been rewritten based on C++ and node-addon-api.

Fixes nodejs#312.

[1] https://github.com/nodejs/node/tree/master/test/node-api/test_threadsafe_function
romandev added a commit to romandev/node-addon-api that referenced this issue Mar 6, 2019
This PR is implementing ThreadSafeFunction class wraps
napi_threadsafe_function features.

FYI, the test files that included in this PR have come from Node.js
repo[1]. They've been rewritten based on C++ and node-addon-api.

Fixes nodejs#312.

[1] https://github.com/nodejs/node/tree/master/test/node-api/test_threadsafe_function
romandev added a commit to romandev/node-addon-api that referenced this issue Mar 6, 2019
This PR is implementing ThreadSafeFunction class wraps
napi_threadsafe_function features.

FYI, the test files that included in this PR have come from Node.js
repo[1]. They've been rewritten based on C++ and node-addon-api.

Fixes nodejs#312.

[1] https://github.com/nodejs/node/tree/master/test/node-api/test_threadsafe_function
romandev added a commit to romandev/node-addon-api that referenced this issue Mar 18, 2019
This PR is implementing ThreadSafeFunction class wraps
napi_threadsafe_function features.

FYI, the test files that included in this PR have come from Node.js
repo[1]. They've been rewritten based on C++ and node-addon-api.

Fixes nodejs#312.

[1] https://github.com/nodejs/node/tree/master/test/node-api/test_threadsafe_function
romandev added a commit to romandev/node-addon-api that referenced this issue Mar 22, 2019
This PR is implementing ThreadSafeFunction class wraps
napi_threadsafe_function features.

FYI, the test files that included in this PR have come from Node.js
repo[1]. They've been rewritten based on C++ and node-addon-api.

Fixes nodejs#312.

[1] https://github.com/nodejs/node/tree/master/test/node-api/test_threadsafe_function
@ghost
Copy link

ghost commented Mar 29, 2019

Is this ready for release ?

romandev added a commit to romandev/node-addon-api that referenced this issue Apr 15, 2019
This PR is implementing ThreadSafeFunction class wraps
napi_threadsafe_function features.

FYI, the test files that included in this PR have come from Node.js
repo[1]. They've been rewritten based on C++ and node-addon-api.

Fixes nodejs#312.

[1] https://github.com/nodejs/node/tree/master/test/node-api/test_threadsafe_function
romandev added a commit to romandev/node-addon-api that referenced this issue Apr 18, 2019
This PR is implementing ThreadSafeFunction class wraps
napi_threadsafe_function features.

FYI, the test files that included in this PR have come from Node.js
repo[1]. They've been rewritten based on C++ and node-addon-api.

Fixes nodejs#312.

[1] https://github.com/nodejs/node/tree/master/test/node-api/test_threadsafe_function
romandev added a commit to romandev/node-addon-api that referenced this issue May 7, 2019
This PR is implementing ThreadSafeFunction class wraps
napi_threadsafe_function features.

FYI, the test files that included in this PR have come from Node.js
repo[1]. They've been rewritten based on C++ and node-addon-api.

Fixes nodejs#312.

[1] https://github.com/nodejs/node/tree/master/test/node-api/test_threadsafe_function
romandev added a commit to romandev/node-addon-api that referenced this issue May 8, 2019
This PR is implementing ThreadSafeFunction class wraps
napi_threadsafe_function features.

FYI, the test files that included in this PR have come from Node.js
repo[1]. They've been rewritten based on C++ and node-addon-api.

Fixes nodejs#312.

[1] https://github.com/nodejs/node/tree/master/test/node-api/test_threadsafe_function
@almoghamdani
Copy link

@romandev Do you have an ETA on when this feature will be released?

romandev added a commit to romandev/node-addon-api that referenced this issue May 15, 2019
This PR is implementing ThreadSafeFunction class wraps
napi_threadsafe_function features.

FYI, the test files that included in this PR have come from Node.js
repo[1]. They've been rewritten based on C++ and node-addon-api.

Fixes nodejs#312.

[1] https://github.com/nodejs/node/tree/master/test/node-api/test_threadsafe_function
@jackwsun2
Copy link

Implement ThreadSafeFunction class

romandev added a commit to romandev/node-addon-api that referenced this issue Jun 14, 2019
This PR is implementing ThreadSafeFunction class wraps
napi_threadsafe_function features.

FYI, the test files that included in this PR have come from Node.js
repo[1]. They've been rewritten based on C++ and node-addon-api.

Fixes nodejs#312.

[1] https://github.com/nodejs/node/tree/master/test/node-api/test_threadsafe_function
romandev added a commit to romandev/node-addon-api that referenced this issue Jun 17, 2019
This PR is implementing ThreadSafeFunction class wraps
napi_threadsafe_function features.

FYI, the test files that included in this PR have come from Node.js
repo[1]. They've been rewritten based on C++ and node-addon-api.

Fixes nodejs#312.

[1] https://github.com/nodejs/node/tree/master/test/node-api/test_threadsafe_function
romandev added a commit to romandev/node-addon-api that referenced this issue Jul 2, 2019
This PR is implementing ThreadSafeFunction class wraps
napi_threadsafe_function features.

FYI, the test files that included in this PR have come from Node.js
repo[1]. They've been rewritten based on C++ and node-addon-api.

Fixes nodejs#312.

[1] https://github.com/nodejs/node/tree/master/test/node-api/test_threadsafe_function
romandev added a commit to romandev/node-addon-api that referenced this issue Jul 3, 2019
This PR is implementing ThreadSafeFunction class wraps
napi_threadsafe_function features.

FYI, the test files that included in this PR have come from Node.js
repo[1]. They've been rewritten based on C++ and node-addon-api.

Fixes nodejs#312.

[1] https://github.com/nodejs/node/tree/master/test/node-api/test_threadsafe_function
@DuBistKomisch
Copy link
Contributor

any plans on doing a release with this, now that the code and docs are merged?

@NickNaso
Copy link
Member

Hi @DuBistKomisch,
you can track the tasks fro the new release in this issue #514

@ghost
Copy link

ghost commented Aug 15, 2019

@romandev Great with this API (!) but are there any examples for how to use the API ?

@DuBistKomisch
Copy link
Contributor

kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this issue Aug 24, 2022
This PR is implementing ThreadSafeFunction class wraps
napi_threadsafe_function features.

FYI, the test files that included in this PR have come from Node.js
repo[1]. They've been rewritten based on C++ and node-addon-api.

[1] https://github.com/nodejs/node/tree/e800f9d/test/node-api/test_threadsafe_function

PR-URL: nodejs/node-addon-api#442
Fixes: nodejs/node-addon-api#312
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Marlyfleitas added a commit to Marlyfleitas/node-api-addon-Development that referenced this issue Aug 26, 2022
This PR is implementing ThreadSafeFunction class wraps
napi_threadsafe_function features.

FYI, the test files that included in this PR have come from Node.js
repo[1]. They've been rewritten based on C++ and node-addon-api.

[1] https://github.com/nodejs/node/tree/e800f9d/test/node-api/test_threadsafe_function

PR-URL: nodejs/node-addon-api#442
Fixes: nodejs/node-addon-api#312
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
wroy7860 added a commit to wroy7860/addon-api-benchmark-node that referenced this issue Sep 19, 2022
This PR is implementing ThreadSafeFunction class wraps
napi_threadsafe_function features.

FYI, the test files that included in this PR have come from Node.js
repo[1]. They've been rewritten based on C++ and node-addon-api.

[1] https://github.com/nodejs/node/tree/e800f9d/test/node-api/test_threadsafe_function

PR-URL: nodejs/node-addon-api#442
Fixes: nodejs/node-addon-api#312
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this issue Aug 11, 2023
This PR is implementing ThreadSafeFunction class wraps
napi_threadsafe_function features.

FYI, the test files that included in this PR have come from Node.js
repo[1]. They've been rewritten based on C++ and node-addon-api.

[1] https://github.com/nodejs/node/tree/e800f9d/test/node-api/test_threadsafe_function

PR-URL: nodejs/node-addon-api#442
Fixes: nodejs/node-addon-api#312
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants