Commit 84bf609 1 parent 2ed10f1 commit 84bf609 Copy full SHA for 84bf609
File tree 3 files changed +19
-8
lines changed
3 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,13 @@ inline AsyncWrap::AsyncWrap(Environment* env,
21
21
// Check user controlled flag to see if the init callback should run.
22
22
if (!env->using_asyncwrap ())
23
23
return ;
24
- if (!env->call_async_init_hook () && parent == nullptr )
24
+
25
+ // If callback hooks have not been enabled, and there is no parent, return.
26
+ if (!env->async_wrap_callbacks_enabled () && parent == nullptr )
27
+ return ;
28
+
29
+ // If callback hooks have not been enabled and parent has no queue, return.
30
+ if (!env->async_wrap_callbacks_enabled () && !parent->has_async_queue ())
25
31
return ;
26
32
27
33
// TODO(trevnorris): Until it's verified all passed object's are not weak,
Original file line number Diff line number Diff line change @@ -66,8 +66,12 @@ inline int Environment::AsyncHooks::fields_count() const {
66
66
return kFieldsCount ;
67
67
}
68
68
69
- inline bool Environment::AsyncHooks::call_init_hook () {
70
- return fields_[kCallInitHook ] != 0 ;
69
+ inline bool Environment::AsyncHooks::callbacks_enabled () {
70
+ return fields_[kEnableCallbacks ] != 0 ;
71
+ }
72
+
73
+ inline void Environment::AsyncHooks::set_enable_callbacks (uint32_t flag) {
74
+ fields_[kEnableCallbacks ] = flag;
71
75
}
72
76
73
77
inline Environment::DomainFlag::DomainFlag () {
@@ -214,9 +218,9 @@ inline v8::Isolate* Environment::isolate() const {
214
218
return isolate_;
215
219
}
216
220
217
- inline bool Environment::call_async_init_hook () const {
221
+ inline bool Environment::async_wrap_callbacks_enabled () const {
218
222
// The const_cast is okay, it doesn't violate conceptual const-ness.
219
- return const_cast <Environment*>(this )->async_hooks ()->call_init_hook ();
223
+ return const_cast <Environment*>(this )->async_hooks ()->callbacks_enabled ();
220
224
}
221
225
222
226
inline bool Environment::in_domain () const {
Original file line number Diff line number Diff line change @@ -269,15 +269,16 @@ class Environment {
269
269
public:
270
270
inline uint32_t * fields ();
271
271
inline int fields_count () const ;
272
- inline bool call_init_hook ();
272
+ inline bool callbacks_enabled ();
273
+ inline void set_enable_callbacks (uint32_t flag);
273
274
274
275
private:
275
276
friend class Environment ; // So we can call the constructor.
276
277
inline AsyncHooks ();
277
278
278
279
enum Fields {
279
280
// Set this to not zero if the init hook should be called.
280
- kCallInitHook ,
281
+ kEnableCallbacks ,
281
282
kFieldsCount
282
283
};
283
284
@@ -374,7 +375,7 @@ class Environment {
374
375
375
376
inline v8::Isolate* isolate () const ;
376
377
inline uv_loop_t * event_loop () const ;
377
- inline bool call_async_init_hook () const ;
378
+ inline bool async_wrap_callbacks_enabled () const ;
378
379
inline bool in_domain () const ;
379
380
inline uint32_t watched_providers () const ;
380
381
You can’t perform that action at this time.
0 commit comments