You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Beside wrapping napi_*_threadsafe I'd also love to see a RunInNodeThread implementation in node-addon-api as an enabler for "concurrent processing" / multithreading and modern C++ with NAPI.
As napi_threadsafe.. API is not fire and forget, but creates objects etc., I wrapped everything in a class which must live on the heap, but threadsafe objects are created once and reused.
The main idea is that we can run RunInNodeThread from any thread:
voidjs_fn(const Napi::CallbackInfo& info) {
// persist callback info[0]std::thread([cb_ref]() { // or a thread pool or Rxint result = heavyProcessing();
RunInNodeThread([result, cb_ref](Napi::Env env) {
// callback cb_ref with result in node thread
});
}
}
This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.
Discussed in the team meeting today. It seems useful, but might fit better in a supporting library and would be a good candidate if we had one that we used to provide wrapper type functions. Unfortunately we don't have that yet.
We discussed again in todays meeting and the what we agreed:
We don't want to pull to much into node-addon-api beyond being a wrapper around the C API, we already have a few different higher level wrappers (PRs like this one) for the Threadsafe function and don't think it would make sense to pull them all in.
We talked about creating a new organization which groups extras for Node-api and in cases like this offer a repo in that org, with the expectation that the author would maintain that repo.
The alternative is of course that authors just create their own repos and we just have a list in the docs which points to that.
Is one of those something that you'd be interested in?
@mhdawson I think that's a good idea.
At current I have no idea when I'll have time to contribute, so I'd be happy (if someone is interested in the idea) to continue it and feel free to use any code sample, ideas etc. to contribute.
Activity
github-actions commentedon Dec 17, 2020
This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.
mhdawson commentedon Jan 15, 2021
We should keep this open, team will try to review so we can discuss in next weeks meeting.
mhdawson commentedon Jan 22, 2021
Discussed in the team meeting today. It seems useful, but might fit better in a supporting library and would be a good candidate if we had one that we used to provide wrapper type functions. Unfortunately we don't have that yet.
mhdawson commentedon Feb 12, 2021
We discussed again in todays meeting and the what we agreed:
Is one of those something that you'd be interested in?
mhdawson commentedon Feb 12, 2021
@DaAitch
DaAitch commentedon Feb 12, 2021
@mhdawson I think that's a good idea.
At current I have no idea when I'll have time to contribute, so I'd be happy (if someone is interested in the idea) to continue it and feel free to use any code sample, ideas etc. to contribute.
I'll close this.