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

Updates for N-API async changes #10

Merged
merged 2 commits into from
Apr 5, 2017
Merged

Updates for N-API async changes #10

merged 2 commits into from
Apr 5, 2017

Conversation

jasongin
Copy link
Member

@jasongin jasongin commented Apr 3, 2017

Updates for pending changes in async APIs at nodejs/abi-stable-node#204, along with other recent changes.

  • Rename napi_work to napi_async_work
  • Async APIs all take an env parameter and return a napi_status
  • New napi_cancel_async_work() API
  • Track (a persistent reference to) an Error object for async work errors, rather than just an error message.
  • Error handling APIs all return a napi_status
  • Reference counts are unsigned

napi-inl.h Outdated
@@ -1316,15 +1322,15 @@ inline T Reference<T>::Value() const {

template <typename T>
inline int Reference<T>::Ref() {
Copy link

Choose a reason for hiding this comment

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

Either the type is wrong or result needs a typecast before returning.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed here and a few other places.

napi-inl.h Outdated
@@ -1316,15 +1322,15 @@ inline T Reference<T>::Value() const {

template <typename T>
inline int Reference<T>::Ref() {
int result;
uint32_t result;
napi_status status = napi_reference_ref(_env, _ref, &result);
if (status != napi_ok) throw Error::New(_env);
return result;
}

template <typename T>
inline int Reference<T>::Unref() {
Copy link

Choose a reason for hiding this comment

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

Either the type is wrong or result needs a typecast before returning.

@jasongin jasongin requested a review from boingoing April 5, 2017 17:09
Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@boingoing boingoing left a comment

Choose a reason for hiding this comment

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

LGTM

@jasongin
Copy link
Member Author

jasongin commented Apr 5, 2017

@boingoing What is the plan for getting the async APIs into node?

Anyway, I don't see any point in holding this PR until those changes land, because the current code in this repo references the old N-API async functions that never landed in node. So updating this repo won't make things any worse.

@boingoing
Copy link

@boingoing What is the plan for getting the async APIs into node?

Prepping the PR for these changes as well as the one which changes napi_callback to return a napi_value. Both should be live today.

Agreed, no reason to hold on the changes in this PR here.

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.

4 participants