-
Notifications
You must be signed in to change notification settings - Fork 30k
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
src,async_hooks,n-api: refactor async callback handling #14697
Conversation
N-API parts look good. I'm still planning to add an async context parameter to If I'm understanding correctly, the change in this PR means that when the N-API async work APIs are used, during the |
@jasongin This PR would mean that |
Oh, so the async work callback should just call Then the only need for |
In that case should |
@jasongin Exactly 👍
Right. Done! |
4dceb50
to
c5cc1cf
Compare
65dfc41
to
b7f6ca7
Compare
Rebased … maybe somebody of @AndreasMadsen @trevnorris @refack @TimothyGu @tniessen @bnoordhuis @jasnell could be reviewer (if only for the yet-unreviewed non-N-API part)? |
doc/api/n-api.md
Outdated
napi_async_execute_callback execute, | ||
napi_async_complete_callback complete, | ||
void* data, | ||
napi_async_work* result); | ||
``` | ||
|
||
- `[in] env`: The environment that the API is invoked under. | ||
- `[in] async_resource_name`: An identifier for the kind of resource that is | ||
being provided for diagnostic information expose by the `async_hooks` 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.
Nit: exposed?
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.
Right, fixed.
With `CallbackScope`, this has become possible to do properly. Fixes: nodejs/node#5691 PR-URL: nodejs/node#14697 Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs/node#14697 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
PR-URL: nodejs/node#14697 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Enable combining N-API async work with async-hooks. PR-URL: nodejs#14697 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jason Ginchereau <jasongin@microsoft.com> Reviewed-By: Michael Dawson <mhdawson@ibm.com>
PR-URL: nodejs#14697 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Enable combining N-API async work with async-hooks. Backport-PR-URL: #19447 PR-URL: #14697 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jason Ginchereau <jasongin@microsoft.com> Reviewed-By: Michael Dawson <mhdawson@ibm.com>
MakeCallback()
implementationsCallbackScope
class for embedders in order to enableMakeCallback()
-like behaviour without tying that to calling a JS functionChecklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
/cc @nodejs/async_hooks
/cc @nodejs/n-api (Who may or may not only want to review the N-API commit; this is a breaking N-API change)