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

n-api: make func argument of napi_create_threadsafe_function optional #27791

Closed
wants to merge 1 commit into from

Conversation

@legendecas
Copy link
Contributor

commented May 21, 2019

Ref: #27592

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@legendecas legendecas force-pushed the legendecas:tsfn branch 2 times, most recently from a2bcde8 to dc0cb8e May 21, 2019

@josephg

This comment has been minimized.

Copy link
Contributor

commented May 21, 2019

Awesome - thanks for putting this together! <3

src/node_api.cc Outdated Show resolved Hide resolved
src/node_api.cc Outdated Show resolved Hide resolved
doc/api/n-api.md Outdated Show resolved Hide resolved
@addaleax

This comment has been minimized.

Copy link
Member

commented May 21, 2019

@nodejs/n-api … how would one feature-detect this? Should we provide that?

@josephg

This comment has been minimized.

Copy link
Contributor

commented May 21, 2019

That would be good - either that or it can be part of the standard API for napi version 5 and later.

src/node_api.cc Outdated Show resolved Hide resolved
src/node_api.cc Outdated Show resolved Hide resolved
src/node_api.cc Outdated Show resolved Hide resolved
test/node-api/test_threadsafe_function/binding.c Outdated Show resolved Hide resolved
@gabrielschulhof

This comment has been minimized.

Copy link
Contributor

commented May 21, 2019

@addaleax you could simply assume that passing func is optional and, if napi_create_threadsafe_function() returns napi_invalid_arg, you would know that you're on a version of N-API where func is mandatory.

I am curious as to the semverity of this change, though. If it's semver-minor, we need to go through the whole experimental life cycle, but I'm not sure how we would do that for a semantic change like this, rather than the clean addition of a new N-API.

@gabrielschulhof

This comment has been minimized.

Copy link
Contributor

commented May 21, 2019

@legendecas please also modify https://nodejs.org/docs/latest/api/n-api.html#n_api_napi_threadsafe_function_call_js by mentioning for the js_callback parameter that it can also be NULL if the thread-safe function was created without a JS callback.

@addaleax

This comment has been minimized.

Copy link
Member

commented May 21, 2019

@addaleax you could simply assume that passing func is optional and, if napi_create_threadsafe_function() returns napi_invalid_arg, you would know that you're on a version of N-API where func is mandatory.

Right, but you usually want to support as many versions as possible, so you’d still end up always providing func, because that’s the only thing you can practically do to resolve napi_invalid_arg, besides maybe erroring out, right?

If it's semver-minor, we need to go through the whole experimental life cycle

Is that a N-API-specific rule that’s written down somewhere? I would consider this semver-minor, but I agree that it doesn’t make sense to label this as experimental. (Fwiw, I think none of the N-API functions currently marked as experimental should be experimental, except maybe the threadsafe function feature due to its complexity.)

@gabrielschulhof

This comment has been minimized.

Copy link
Contributor

commented May 21, 2019

@addaleax you could simply assume that passing func is optional and, if napi_create_threadsafe_function() returns napi_invalid_arg, you would know that you're on a version of N-API where func is mandatory.

Right, but you usually want to support as many versions as possible, so you’d still end up always providing func, because that’s the only thing you can practically do to resolve napi_invalid_arg, besides maybe erroring out, right?

Well, if you get napi_invalid_arg, and knowing that the call should succeed, you would call again with a non-NULL func. But, of course, passing a dummy func is simplest.

My take is that this change is more about making napi_threadsafe_function into an async queue, which would clean up code that builds upon it, than it is about what to do with func.

If it's semver-minor, we need to go through the whole experimental life cycle

Is that a N-API-specific rule that’s written down somewhere? I would consider this semver-minor, but I agree that it doesn’t make sense to label this as experimental. (Fwiw, I think none of the N-API functions currently marked as experimental should be experimental, except maybe the threadsafe function feature due to its complexity.)

Well, the rule concerns new N-APIs. This isn't strictly a new N-API 🙂 But yeah, a semver-minor bump sounds like the way to go.

@legendecas legendecas force-pushed the legendecas:tsfn branch from dc0cb8e to 3767947 May 22, 2019

@gabrielschulhof
Copy link
Contributor

left a comment

Excellent progress! A few minor changes and it'll be golden 👍

doc/api/n-api.md Outdated Show resolved Hide resolved
doc/api/n-api.md Outdated Show resolved Hide resolved
src/node_api.cc Outdated Show resolved Hide resolved
@mhdawson

This comment has been minimized.

Copy link
Member

commented May 22, 2019

I think we can be flexible on going through an experimental cycle. For new functions, I think it makes sense and we should stick to that. In this case I think we'll get agreement that we should just do this immediately. My preference would be to make the change, and bump the N-API version in the same PR. In that way you will know you can depend on the parameter being optional if it is version 5 or higher. We might also want to review if we should promote any other functions out of experimental at the same time as we bump the version number (being careful to think about whether those other changes can be backported in case we want to backport version 5 support to 10.x and 8.x)

@legendecas legendecas force-pushed the legendecas:tsfn branch 2 times, most recently from 7bfb88f to b985dd2 May 24, 2019

doc/api/n-api.md Outdated Show resolved Hide resolved
@gabrielschulhof
Copy link
Contributor

left a comment

Not actually requesting changes. On my part the PR is approved as is, however, I'm marking it as "Request changes" so as to prevent it from landing before we've had a chance to co-ordinate what else should be added to N-API 5.

@legendecas legendecas force-pushed the legendecas:tsfn branch 2 times, most recently from bc653a9 to 4142960 May 27, 2019

@Trott

This comment has been minimized.

Copy link
Member

commented May 27, 2019

Not actually requesting changes. On my part the PR is approved as is, however, I'm marking it as "Request changes" so as to prevent it from landing before we've had a chance to co-ordinate what else should be added to N-API 5.

@gabrielschulhof Alternatively, you could approve it but add one of the blocked or wip labels. (But if a Request Changes is the best workflow for you, then by all means, do that.)

Using the method mentioned by @Trott instead.

doc/api/n-api.md Outdated Show resolved Hide resolved
doc/api/n-api.md Outdated Show resolved Hide resolved
@nodejs-github-bot

This comment has been minimized.

@gabrielschulhof

This comment has been minimized.

Copy link
Contributor

commented Jun 20, 2019

@nodejs/build can you please help me out here? The one failing job is from a different build. I don't get how come https://ci.nodejs.org/job/node-test-pull-request/24016/ didn't replace the job from https://ci.nodejs.org/job/node-test-pull-request/23975/.

@Trott

This comment has been minimized.

Copy link
Member

commented Jun 22, 2019

@nodejs/build can you please help me out here? The one failing job is from a different build. I don't get how come https://ci.nodejs.org/job/node-test-pull-request/24016/ didn't replace the job from https://ci.nodejs.org/job/node-test-pull-request/23975/.

You can ignore the GitHub widget if it conflicts with what the actual Jenkins CI is telling you.

Trott added a commit to Trott/io.js that referenced this pull request Jun 22, 2019
n-api: make func argument of napi_create_threadsafe_function optional
PR-URL: nodejs#27791
Refs: nodejs#27592
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
@Trott

This comment has been minimized.

Copy link
Member

commented Jun 22, 2019

Landed in 5705d7b

@Trott Trott closed this Jun 22, 2019

@legendecas legendecas deleted the legendecas:tsfn branch Jun 22, 2019

@gabrielschulhof

This comment has been minimized.

Copy link
Contributor

commented Jun 23, 2019

@Trott thanks! Will do in the future.

gabrielschulhof added a commit to gabrielschulhof/node that referenced this pull request Jun 23, 2019
n-api: make func argument of napi_create_threadsafe_function optional
PR-URL: nodejs#27791
Refs: nodejs#27592
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
gabrielschulhof added a commit to gabrielschulhof/node that referenced this pull request Jun 24, 2019
n-api: make func argument of napi_create_threadsafe_function optional
PR-URL: nodejs#27791
Refs: nodejs#27592
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
richardlau added a commit to richardlau/node-1 that referenced this pull request Jun 24, 2019
doc,n-api: fix metadata for napi_create_threadsafe_function
PR-URL: nodejs#28410
Refs: nodejs#27791
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
jshricarde added a commit to jshricarde/node that referenced this pull request Jun 25, 2019
n-api: make func argument of napi_create_threadsafe_function optional
PR-URL: nodejs#27791
Refs: nodejs#27592
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
jshricarde added a commit to jshricarde/node that referenced this pull request Jun 25, 2019
doc,n-api: fix metadata for napi_create_threadsafe_function
PR-URL: nodejs#28410
Refs: nodejs#27791
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
gabrielschulhof added a commit to gabrielschulhof/node that referenced this pull request Jun 28, 2019
n-api: make func argument of napi_create_threadsafe_function optional
PR-URL: nodejs#27791
Refs: nodejs#27592
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
gabrielschulhof added a commit to gabrielschulhof/node that referenced this pull request Jul 1, 2019
n-api: make func argument of napi_create_threadsafe_function optional
PR-URL: nodejs#27791
Refs: nodejs#27592
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
targos added a commit that referenced this pull request Jul 2, 2019
n-api: make func argument of napi_create_threadsafe_function optional
PR-URL: #27791
Refs: #27592
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
targos added a commit that referenced this pull request Jul 2, 2019
doc,n-api: fix metadata for napi_create_threadsafe_function
PR-URL: #28410
Refs: #27791
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
@targos targos referenced this pull request Jul 2, 2019
gabrielschulhof added a commit to gabrielschulhof/node that referenced this pull request Jul 12, 2019
n-api: make func argument of napi_create_threadsafe_function optional
PR-URL: nodejs#27791
Refs: nodejs#27592
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
gabrielschulhof added a commit to gabrielschulhof/node that referenced this pull request Sep 2, 2019
n-api: make func argument of napi_create_threadsafe_function optional
PR-URL: nodejs#27791
Refs: nodejs#27592
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
gabrielschulhof added a commit to gabrielschulhof/node that referenced this pull request Sep 2, 2019
n-api: make func argument of napi_create_threadsafe_function optional
PR-URL: nodejs#27791
Refs: nodejs#27592
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
Projects
None yet
9 participants
You can’t perform that action at this time.