@@ -44,6 +44,7 @@ using v8::MaybeLocal;
4444using v8::Nothing;
4545using v8::Number;
4646using v8::Object;
47+ using v8::ObjectTemplate;
4748using v8::PropertyAttribute;
4849using v8::ReadOnly;
4950using v8::String;
@@ -351,24 +352,31 @@ Local<FunctionTemplate> AsyncWrap::GetConstructorTemplate(
351352 return tmpl;
352353}
353354
354- void AsyncWrap::Initialize (Local<Object> target,
355- Local<Value> unused,
356- Local<Context> context,
357- void * priv) {
355+ void AsyncWrap::CreatePerIsolateProperties (IsolateData* isolate_data,
356+ Local<FunctionTemplate> ctor) {
357+ Isolate* isolate = isolate_data->isolate ();
358+ Local<ObjectTemplate> target = ctor->InstanceTemplate ();
359+
360+ SetMethod (isolate, target, " setupHooks" , SetupHooks);
361+ SetMethod (isolate, target, " setCallbackTrampoline" , SetCallbackTrampoline);
362+ SetMethod (isolate, target, " pushAsyncContext" , PushAsyncContext);
363+ SetMethod (isolate, target, " popAsyncContext" , PopAsyncContext);
364+ SetMethod (isolate, target, " executionAsyncResource" , ExecutionAsyncResource);
365+ SetMethod (isolate, target, " clearAsyncIdStack" , ClearAsyncIdStack);
366+ SetMethod (isolate, target, " queueDestroyAsyncId" , QueueDestroyAsyncId);
367+ SetMethod (isolate, target, " setPromiseHooks" , SetPromiseHooks);
368+ SetMethod (isolate, target, " registerDestroyHook" , RegisterDestroyHook);
369+ AsyncWrap::GetConstructorTemplate (isolate_data);
370+ }
371+
372+ void AsyncWrap::CreatePerContextProperties (Local<Object> target,
373+ Local<Value> unused,
374+ Local<Context> context,
375+ void * priv) {
358376 Environment* env = Environment::GetCurrent (context);
359377 Isolate* isolate = env->isolate ();
360378 HandleScope scope (isolate);
361379
362- SetMethod (context, target, " setupHooks" , SetupHooks);
363- SetMethod (context, target, " setCallbackTrampoline" , SetCallbackTrampoline);
364- SetMethod (context, target, " pushAsyncContext" , PushAsyncContext);
365- SetMethod (context, target, " popAsyncContext" , PopAsyncContext);
366- SetMethod (context, target, " executionAsyncResource" , ExecutionAsyncResource);
367- SetMethod (context, target, " clearAsyncIdStack" , ClearAsyncIdStack);
368- SetMethod (context, target, " queueDestroyAsyncId" , QueueDestroyAsyncId);
369- SetMethod (context, target, " setPromiseHooks" , SetPromiseHooks);
370- SetMethod (context, target, " registerDestroyHook" , RegisterDestroyHook);
371-
372380 PropertyAttribute ReadOnlyDontDelete =
373381 static_cast <PropertyAttribute>(ReadOnly | DontDelete);
374382
@@ -625,7 +633,6 @@ void AsyncWrap::AsyncReset(Local<Object> resource, double execution_async_id,
625633 async_id_, trigger_async_id_);
626634}
627635
628-
629636void AsyncWrap::EmitAsyncInit (Environment* env,
630637 Local<Object> object,
631638 Local<String> type,
@@ -710,6 +717,9 @@ Local<Object> AsyncWrap::GetOwner(Environment* env, Local<Object> obj) {
710717
711718} // namespace node
712719
713- NODE_BINDING_CONTEXT_AWARE_INTERNAL (async_wrap, node::AsyncWrap::Initialize)
720+ NODE_BINDING_CONTEXT_AWARE_INTERNAL (async_wrap,
721+ node::AsyncWrap::CreatePerContextProperties)
722+ NODE_BINDING_PER_ISOLATE_INIT(async_wrap,
723+ node::AsyncWrap::CreatePerIsolateProperties)
714724NODE_BINDING_EXTERNAL_REFERENCE(async_wrap,
715725 node::AsyncWrap::RegisterExternalReferences)
0 commit comments