diff options
Diffstat (limited to 'src/node_internals.h')
-rw-r--r-- | src/node_internals.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/node_internals.h b/src/node_internals.h index 9371d442ad..fd8cc26a28 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -294,8 +294,36 @@ v8::MaybeLocal<v8::Value> InternalMakeCallback( v8::Local<v8::Value> argv[], async_context asyncContext); +class InternalCallbackScope { + public: + // Tell the constructor whether its `object` parameter may be empty or not. + enum ResourceExpectation { kRequireResource, kAllowEmptyResource }; + InternalCallbackScope(Environment* env, + v8::Local<v8::Object> object, + const async_context& asyncContext, + ResourceExpectation expect = kRequireResource); + ~InternalCallbackScope(); + void Close(); + + inline bool Failed() const { return failed_; } + inline void MarkAsFailed() { failed_ = true; } + inline bool IsInnerMakeCallback() const { + return callback_scope_.in_makecallback(); + } + + private: + Environment* env_; + async_context async_context_; + v8::Local<v8::Object> object_; + Environment::AsyncCallbackScope callback_scope_; + bool failed_ = false; + bool pushed_ids_ = false; + bool closed_ = false; +}; + } // namespace node + #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #endif // SRC_NODE_INTERNALS_H_ |