diff options
author | Trevor Norris <trev.norris@gmail.com> | 2016-01-05 15:33:21 -0700 |
---|---|---|
committer | Trevor Norris <trev.norris@gmail.com> | 2016-02-12 14:03:24 -0700 |
commit | e9192249c8c6b05c7cc04e8b51a7e37235f31415 (patch) | |
tree | 8859fa3eb0090035dae60d813b9f315b456413bb /src/env-inl.h | |
parent | 575b84ec41b94d4a565b981c146d88ce0637fff2 (diff) | |
download | node-new-e9192249c8c6b05c7cc04e8b51a7e37235f31415.tar.gz |
src: add AsyncCallbackScope
Add a scope that will allow MakeCallback to know whether or not it's
currently running. This will prevent nextTickQueue and the
MicrotaskQueue from being processed recursively. It is also required to
wrap the bootloading stage since it doesn't run within a MakeCallback.
Ref: https://github.com/nodejs/node-v0.x-archive/issues/9245
PR-URL: https://github.com/nodejs/node/pull/4507
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'src/env-inl.h')
-rw-r--r-- | src/env-inl.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/env-inl.h b/src/env-inl.h index 46272585d5..c09fb87897 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -101,6 +101,20 @@ inline void Environment::AsyncHooks::set_enable_callbacks(uint32_t flag) { fields_[kEnableCallbacks] = flag; } +inline Environment::AsyncCallbackScope::AsyncCallbackScope(Environment* env) + : env_(env) { + env_->makecallback_cntr_++; +} + +inline Environment::AsyncCallbackScope::~AsyncCallbackScope() { + env_->makecallback_cntr_--; + CHECK_GE(env_->makecallback_cntr_, 0); +} + +inline bool Environment::AsyncCallbackScope::in_makecallback() { + return env_->makecallback_cntr_ > 1; +} + inline Environment::DomainFlag::DomainFlag() { for (int i = 0; i < kFieldsCount; ++i) fields_[i] = 0; } @@ -223,6 +237,7 @@ inline Environment::Environment(v8::Local<v8::Context> context, using_domains_(false), printed_error_(false), trace_sync_io_(false), + makecallback_cntr_(0), async_wrap_uid_(0), debugger_agent_(this), http_parser_buffer_(nullptr), |