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

update for latest n-api changes #140

Closed
wants to merge 2 commits into from
Closed

Conversation

mhdawson
Copy link
Member

@mhdawson mhdawson commented Sep 19, 2017

There is a better way to handle the changes for async hooks, this gets it compiling/working but I know its not right @jasongin can you suggest what we should be doing in terms of properly supporting the new async hook parameters.

@mhdawson
Copy link
Member Author

@gabrielschulhof the other thing of note in this is that I had to add uv.h and node.h to node_internals.h because of refactoring that took place in the node files.

I'm wondering who we could have built the wrapper without the vm as node_api.cc would have needed uv.h and node.h ?

Maybe its just late and I'm tired though ?

@jasongin
Copy link
Member

Following is an outline of the updates required for the async hooks changes:

  • Define a C++ type for the new napi_async_context type; its initialization calls napi_async_init() and destruction calls napi_async_delete(). (Think carefully about how the async context lifetime is managed using C++ constructor/destructor semantics.)
  • Add an async context parameter to all MakeCallback() function overloads.
  • Add async resource and resource-name parameters to the AsyncWorker constructor and pass those to napi_create_async_work(). (Optionally the async resource object can be the same as the receiver parameter.)
  • Change AsyncWorker::OnOK() and AsyncWorker::OnError() callbacks to not use MakeCallback(). An ordinary function call (_callback::Call()) is now correct.

Since it's not trivial, it's probably better to do as a separate PR.

@mhdawson
Copy link
Member Author

mhdawson commented Sep 20, 2017

@jasongin so are you suggesting that we land this PR as is and then do a follow on PR to cover the steps you have outline ? That would make sense to me. It would let us address the current breakage so that we minimize the time people can't use the wrapper with master (and 8.6 when goes out soon)

@jasongin
Copy link
Member

Yes.

@mhdawson
Copy link
Member Author

Ok then @jasongin need a review on this PR so I can land.

ModuleRegisterCallback registerCallback) {
return details::WrapCallback([&] {
return napi_value(registerCallback(Napi::Env(env),
Napi::Object(env, exports)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The last line here should be indented further to align with the previous argument.

Or, the explicit napi_value() constructor can be omitted because that conversion can be implicit.


napi_value resource_id;
napi_status status = napi_create_string_latin1(
_env, "generic", -1, &resource_id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this much, but it's fine for now. The follow-up changes will move this resource name string to a parameter of the AsyncWorker constructor.

@mhdawson
Copy link
Member Author

Will land and address @jasongin comments.

mhdawson added a commit that referenced this pull request Sep 21, 2017
PR-URL: #140
Reviewed-By: Jason Ginchereau <jasongin@microsoft.com>
@mhdawson
Copy link
Member Author

Landed as 8b66730

@mhdawson mhdawson closed this Sep 21, 2017
romandev added a commit to romandev/node-addon-api that referenced this pull request Apr 28, 2018
romandev added a commit to romandev/node-addon-api that referenced this pull request May 20, 2018
romandev added a commit to romandev/node-addon-api that referenced this pull request May 20, 2018
mhdawson pushed a commit that referenced this pull request May 25, 2018
This change is initiated from
#140 (comment).

PR-URL: #253
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Nicola Del Gobbo <nicoladelgobbo@NickNaso.local>
kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this pull request Aug 24, 2022
PR-URL: nodejs/node-addon-api#140
Reviewed-By: Jason Ginchereau <jasongin@microsoft.com>
kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this pull request Aug 24, 2022
This change is initiated from
nodejs/node-addon-api#140 (comment).

PR-URL: nodejs/node-addon-api#253
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Nicola Del Gobbo <nicoladelgobbo@NickNaso.local>
Marlyfleitas added a commit to Marlyfleitas/node-api-addon-Development that referenced this pull request Aug 26, 2022
PR-URL: nodejs/node-addon-api#140
Reviewed-By: Jason Ginchereau <jasongin@microsoft.com>
Marlyfleitas added a commit to Marlyfleitas/node-api-addon-Development that referenced this pull request Aug 26, 2022
This change is initiated from
nodejs/node-addon-api#140 (comment).

PR-URL: nodejs/node-addon-api#253
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Nicola Del Gobbo <nicoladelgobbo@NickNaso.local>
wroy7860 added a commit to wroy7860/addon-api-benchmark-node that referenced this pull request Sep 19, 2022
PR-URL: nodejs/node-addon-api#140
Reviewed-By: Jason Ginchereau <jasongin@microsoft.com>
wroy7860 added a commit to wroy7860/addon-api-benchmark-node that referenced this pull request Sep 19, 2022
This change is initiated from
nodejs/node-addon-api#140 (comment).

PR-URL: nodejs/node-addon-api#253
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Nicola Del Gobbo <nicoladelgobbo@NickNaso.local>
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this pull request Aug 11, 2023
PR-URL: nodejs/node-addon-api#140
Reviewed-By: Jason Ginchereau <jasongin@microsoft.com>
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this pull request Aug 11, 2023
This change is initiated from
nodejs/node-addon-api#140 (comment).

PR-URL: nodejs/node-addon-api#253
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Nicola Del Gobbo <nicoladelgobbo@NickNaso.local>
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 this pull request may close these issues.

2 participants