-
-
Notifications
You must be signed in to change notification settings - Fork 34.8k
async-wrap: always call before and after hooks #665
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,7 +55,6 @@ inline v8::Isolate* Environment::IsolateData::isolate() const { | |
| } | ||
|
|
||
| inline Environment::AsyncHooks::AsyncHooks() { | ||
| enabled = false; | ||
| for (int i = 0; i < kFieldsCount; i++) fields_[i] = 0; | ||
| } | ||
|
|
||
|
|
@@ -71,6 +70,14 @@ inline bool Environment::AsyncHooks::call_init_hook() { | |
| return fields_[kCallInitHook] != 0; | ||
| } | ||
|
|
||
| inline bool Environment::AsyncHooks::is_enabled() const { | ||
| return fields_[kEnabled] != 0; | ||
| } | ||
|
|
||
| inline void Environment::AsyncHooks::set_enabled(bool enabled) { | ||
| fields_[kEnabled] = (uint32_t)enabled; | ||
|
||
| } | ||
|
|
||
| inline Environment::DomainFlag::DomainFlag() { | ||
| for (int i = 0; i < kFieldsCount; ++i) fields_[i] = 0; | ||
| } | ||
|
|
@@ -217,7 +224,7 @@ inline v8::Isolate* Environment::isolate() const { | |
|
|
||
| inline bool Environment::use_async_hook() const { | ||
| // The const_cast is okay, it doesn't violate conceptual const-ness. | ||
| return const_cast<Environment*>(this)->async_hooks()->enabled; | ||
| return const_cast<Environment*>(this)->async_hooks()->is_enabled(); | ||
| } | ||
|
|
||
| inline bool Environment::call_async_init_hook() const { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -255,7 +255,8 @@ class Environment { | |
| inline uint32_t* fields(); | ||
| inline int fields_count() const; | ||
| inline bool call_init_hook(); | ||
| bool enabled; | ||
| inline bool is_enabled() const; | ||
| inline void set_enabled(bool enabled); | ||
|
|
||
| private: | ||
| friend class Environment; // So we can call the constructor. | ||
|
|
@@ -264,6 +265,9 @@ class Environment { | |
| enum Fields { | ||
| // Set this to not zero if the init hook should be called. | ||
| kCallInitHook, | ||
| // Set this to not zero if async wrap should be enabled. This is | ||
| // automatically set when SetupHooks is called. | ||
| kEnabled, | ||
|
||
| kFieldsCount | ||
| }; | ||
|
|
||
|
|
||
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.
I don't see a test added to check
kEnabled.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.
Also, can you distinguish what "JS hook functions" this means? There are 4 of them, and this doesn't affect them all.
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.
There are 3 of them (
init,preandpost), right? This should affect all of them.I will add a test case then. I was just unsure about the test policy for async wrap.