@@ -61,7 +61,7 @@ inline AsyncWrap::AsyncWrap(Environment* env,
6161
6262 if (parent_has_async_queue) {
6363 parent_val = parent->object ().As <v8::Value>();
64- env->async_listener_load_function ()-> Call ( process, 1 , &parent_val);
64+ Call ( env->async_listener_load_function (), process, 1 , &parent_val);
6565
6666 if (try_catch.HasCaught ())
6767 return ;
@@ -71,22 +71,31 @@ inline AsyncWrap::AsyncWrap(Environment* env,
7171 object.As <v8::Value>(),
7272 v8::Integer::NewFromUnsigned (env->isolate (), provider)
7373 };
74- env->async_listener_run_function ()-> Call ( process, ARRAY_SIZE (val_v), val_v);
74+ Call ( env->async_listener_run_function (), process, ARRAY_SIZE (val_v), val_v);
7575
7676 if (!try_catch.HasCaught ())
7777 async_flags_ |= HAS_ASYNC_LISTENER;
7878 else
7979 return ;
8080
8181 if (parent_has_async_queue)
82- env->async_listener_unload_function ()-> Call ( process, 1 , &parent_val);
82+ Call ( env->async_listener_unload_function (), process, 1 , &parent_val);
8383}
8484
8585
8686inline AsyncWrap::~AsyncWrap () {
8787}
8888
8989
90+ inline void AsyncWrap::Call (v8::Local<v8::Function> func,
91+ v8::Handle<v8::Object> recv,
92+ size_t argc,
93+ v8::Handle<v8::Value>* argv) {
94+ if (!func->IsUndefined ())
95+ func->Call (recv, argc, argv);
96+ }
97+
98+
9099template <class Type >
91100inline void AsyncWrap::AddMethods (v8::Local<v8::FunctionTemplate> t) {
92101 NODE_SET_PROTOTYPE_METHOD (t, " _removeAsyncQueue" , RemoveAsyncQueue<Type>);
@@ -118,7 +127,7 @@ inline v8::Handle<v8::Value> AsyncWrap::MakeCallback(
118127
119128 if (has_async_queue ()) {
120129 v8::Local<v8::Value> val = context.As <v8::Value>();
121- env ()->async_listener_load_function ()-> Call ( process, 1 , &val);
130+ Call ( env ()->async_listener_load_function (), process, 1 , &val);
122131
123132 if (try_catch.HasCaught ())
124133 return v8::Undefined (env ()->isolate ());
@@ -164,7 +173,7 @@ inline v8::Handle<v8::Value> AsyncWrap::MakeCallback(
164173
165174 if (has_async_queue ()) {
166175 v8::Local<v8::Value> val = context.As <v8::Value>();
167- env ()->async_listener_unload_function ()-> Call ( process, 1 , &val);
176+ Call ( env ()->async_listener_unload_function (), process, 1 , &val);
168177
169178 if (try_catch.HasCaught ())
170179 return Undefined (env ()->isolate ());
0 commit comments