1+ #include " async_wrap.h"
12#include " env-inl.h"
23#include " node_internals.h"
34#include " node_process-inl.h"
4- #include " async_wrap.h"
55
66namespace node {
77
@@ -127,18 +127,16 @@ struct ACHHandle final {
127127// this.
128128void DeleteACHHandle::operator ()(ACHHandle* handle) const { delete handle; }
129129
130- void AddEnvironmentCleanupHook (Isolate* isolate,
131- CleanupHook fun,
132- void * arg) {
133- Environment* env = Environment::GetCurrent (isolate);
130+ void AddEnvironmentCleanupHook (Isolate* isolate, CleanupHook fun, void * arg) {
131+ Environment* env = Environment::GetCurrent (isolate->GetCurrentContext ());
134132 CHECK_NOT_NULL (env);
135133 env->AddCleanupHook (fun, arg);
136134}
137135
138136void RemoveEnvironmentCleanupHook (Isolate* isolate,
139137 CleanupHook fun,
140138 void * arg) {
141- Environment* env = Environment::GetCurrent (isolate);
139+ Environment* env = Environment::GetCurrent (isolate-> GetCurrentContext () );
142140 CHECK_NOT_NULL (env);
143141 env->RemoveCleanupHook (fun, arg);
144142}
@@ -158,11 +156,10 @@ static void RunAsyncCleanupHook(void* arg) {
158156 info->fun (info->arg , FinishAsyncCleanupHook, info);
159157}
160158
161- ACHHandle* AddEnvironmentCleanupHookInternal (
162- Isolate* isolate,
163- AsyncCleanupHook fun,
164- void * arg) {
165- Environment* env = Environment::GetCurrent (isolate);
159+ ACHHandle* AddEnvironmentCleanupHookInternal (Isolate* isolate,
160+ AsyncCleanupHook fun,
161+ void * arg) {
162+ Environment* env = Environment::GetCurrent (isolate->GetCurrentContext ());
166163 CHECK_NOT_NULL (env);
167164 auto info = std::make_shared<AsyncCleanupHookInfo>();
168165 info->env = env;
@@ -191,7 +188,7 @@ void RequestInterrupt(Environment* env, void (*fun)(void* arg), void* arg) {
191188}
192189
193190async_id AsyncHooksGetExecutionAsyncId (Isolate* isolate) {
194- Environment* env = Environment::GetCurrent (isolate);
191+ Environment* env = Environment::GetCurrent (isolate-> GetCurrentContext () );
195192 if (env == nullptr ) return -1 ;
196193 return env->execution_async_id ();
197194}
@@ -203,12 +200,11 @@ async_id AsyncHooksGetExecutionAsyncId(Local<Context> context) {
203200}
204201
205202async_id AsyncHooksGetTriggerAsyncId (Isolate* isolate) {
206- Environment* env = Environment::GetCurrent (isolate);
203+ Environment* env = Environment::GetCurrent (isolate-> GetCurrentContext () );
207204 if (env == nullptr ) return -1 ;
208205 return env->trigger_async_id ();
209206}
210207
211-
212208async_context EmitAsyncInit (Isolate* isolate,
213209 Local<Object> resource,
214210 const char * name,
@@ -225,7 +221,7 @@ async_context EmitAsyncInit(Isolate* isolate,
225221 Local<String> name,
226222 async_id trigger_async_id) {
227223 DebugSealHandleScope handle_scope (isolate);
228- Environment* env = Environment::GetCurrent (isolate);
224+ Environment* env = Environment::GetCurrent (isolate-> GetCurrentContext () );
229225 CHECK_NOT_NULL (env);
230226
231227 // Initialize async context struct
@@ -245,7 +241,8 @@ async_context EmitAsyncInit(Isolate* isolate,
245241}
246242
247243void EmitAsyncDestroy (Isolate* isolate, async_context asyncContext) {
248- EmitAsyncDestroy (Environment::GetCurrent (isolate), asyncContext);
244+ EmitAsyncDestroy (Environment::GetCurrent (isolate->GetCurrentContext ()),
245+ asyncContext);
249246}
250247
251248void EmitAsyncDestroy (Environment* env, async_context asyncContext) {
0 commit comments