-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
doc,src: clarify that one napi_env is for each specific module #31102
Conversation
/cc @nodejs/n-api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
doc/api/n-api.md
Outdated
not allowed. | ||
nested N-API calls. `napi_env` can be used through the context with the module, | ||
that is to say, `napi_env` can not be used mixed up in [`Worker`][] threads, | ||
and caching the `napi_env` for the purpose of general reuse is not allowed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should just change the last sentence to this:
"Caching the `napi_env` for the purpose of general reuse, and passing the napi_env
between instances of the same addon running on different [`Worker`][] threads is not allowed. The napi_env
becomes invalid when an instance of a native addon is unloaded. Notification of this event is delivered through the callbacks given to [`napi_add_env_cleanup_hook`][] and [`napi_set_instance_data`][]."
Ping @legendecas |
@gabrielschulhof Updated :D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@legendecas looks like the linter failed. Can you review the failures and update. |
PR-URL: #31102 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Landed in 96eceb7. |
PR-URL: #31102 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
PR-URL: #31102 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
One napi_env is for each specific module in one context.
Related: #28682
Fixes: #31003
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes