GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: add helper for before/after scope without JS calls · nodejs/node@f7f1437

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • async_wrap-inl.h
    • async_wrap.h
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/async_wrap-inl.h‎

Copy file name to clipboardExpand all lines: src/async_wrap-inl.h
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,22 @@ inline double AsyncWrap::get_trigger_async_id() const {
4545
}
4646

4747

48+
inline AsyncWrap::AsyncScope::AsyncScope(AsyncWrap* wrap)
49+
: wrap_(wrap) {
50+
Environment* env = wrap->env();
51+
if (env->async_hooks()->fields()[Environment::AsyncHooks::kBefore] == 0)
52+
return;
53+
EmitBefore(env, wrap->get_async_id());
54+
}
55+
56+
inline AsyncWrap::AsyncScope::~AsyncScope() {
57+
Environment* env = wrap_->env();
58+
if (env->async_hooks()->fields()[Environment::AsyncHooks::kAfter] == 0)
59+
return;
60+
EmitAfter(env, wrap_->get_async_id());
61+
}
62+
63+
4864
inline v8::MaybeLocal<v8::Value> AsyncWrap::MakeCallback(
4965
const v8::Local<v8::String> symbol,
5066
int argc,
Collapse file

‎src/async_wrap.h‎

Copy file name to clipboardExpand all lines: src/async_wrap.h
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,18 @@ class AsyncWrap : public BaseObject {
169169

170170
static void WeakCallback(const v8::WeakCallbackInfo<DestroyParam> &info);
171171

172+
// This is a simplified version of InternalCallbackScope that only runs
173+
// the `before` and `after` hooks. Only use it when not actually calling
174+
// back into JS; otherwise, use InternalCallbackScope.
175+
class AsyncScope {
176+
public:
177+
explicit inline AsyncScope(AsyncWrap* wrap);
178+
~AsyncScope();
179+
180+
private:
181+
AsyncWrap* wrap_ = nullptr;
182+
};
183+
172184
private:
173185
friend class PromiseWrap;
174186

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.