diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-03-07 17:55:24 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-03-15 12:53:07 +0100 |
commit | f7f1437d44f3e4b745e36540a752065cc58d993b (patch) | |
tree | 39493f25b64da7761cb0fb142c95cb121e3d0f7c /src/async_wrap.h | |
parent | f734b3eb04c0d355ef7ab893ed5869b867d35642 (diff) | |
download | android-node-v8-f7f1437d44f3e4b745e36540a752065cc58d993b.tar.gz android-node-v8-f7f1437d44f3e4b745e36540a752065cc58d993b.tar.bz2 android-node-v8-f7f1437d44f3e4b745e36540a752065cc58d993b.zip |
src: add helper for before/after scope without JS calls
Add `AsyncScope` for cases where the async_hooks `before` and
`after` callbacks should be called, to track async context,
but no actual JS is called in between and we can therefore
skip things like draining the microtask or `nextTick` queues.
PR-URL: https://github.com/nodejs/node/pull/18936
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'src/async_wrap.h')
-rw-r--r-- | src/async_wrap.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/async_wrap.h b/src/async_wrap.h index b7aed5d789..608764bab5 100644 --- a/src/async_wrap.h +++ b/src/async_wrap.h @@ -169,6 +169,18 @@ class AsyncWrap : public BaseObject { static void WeakCallback(const v8::WeakCallbackInfo<DestroyParam> &info); + // This is a simplified version of InternalCallbackScope that only runs + // the `before` and `after` hooks. Only use it when not actually calling + // back into JS; otherwise, use InternalCallbackScope. + class AsyncScope { + public: + explicit inline AsyncScope(AsyncWrap* wrap); + ~AsyncScope(); + + private: + AsyncWrap* wrap_ = nullptr; + }; + private: friend class PromiseWrap; |