1
+ #include " async_wrap.h"
1
2
#include " env-inl.h"
2
3
#include " node_internals.h"
3
4
#include " node_process-inl.h"
4
- #include " async_wrap.h"
5
5
6
6
namespace node {
7
7
@@ -127,18 +127,16 @@ struct ACHHandle final {
127
127
// this.
128
128
void DeleteACHHandle::operator ()(ACHHandle* handle) const { delete handle; }
129
129
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 ());
134
132
CHECK_NOT_NULL (env);
135
133
env->AddCleanupHook (fun, arg);
136
134
}
137
135
138
136
void RemoveEnvironmentCleanupHook (Isolate* isolate,
139
137
CleanupHook fun,
140
138
void * arg) {
141
- Environment* env = Environment::GetCurrent (isolate);
139
+ Environment* env = Environment::GetCurrent (isolate-> GetCurrentContext () );
142
140
CHECK_NOT_NULL (env);
143
141
env->RemoveCleanupHook (fun, arg);
144
142
}
@@ -158,11 +156,10 @@ static void RunAsyncCleanupHook(void* arg) {
158
156
info->fun (info->arg , FinishAsyncCleanupHook, info);
159
157
}
160
158
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 ());
166
163
CHECK_NOT_NULL (env);
167
164
auto info = std::make_shared<AsyncCleanupHookInfo>();
168
165
info->env = env;
@@ -191,7 +188,7 @@ void RequestInterrupt(Environment* env, void (*fun)(void* arg), void* arg) {
191
188
}
192
189
193
190
async_id AsyncHooksGetExecutionAsyncId (Isolate* isolate) {
194
- Environment* env = Environment::GetCurrent (isolate);
191
+ Environment* env = Environment::GetCurrent (isolate-> GetCurrentContext () );
195
192
if (env == nullptr ) return -1 ;
196
193
return env->execution_async_id ();
197
194
}
@@ -203,12 +200,11 @@ async_id AsyncHooksGetExecutionAsyncId(Local<Context> context) {
203
200
}
204
201
205
202
async_id AsyncHooksGetTriggerAsyncId (Isolate* isolate) {
206
- Environment* env = Environment::GetCurrent (isolate);
203
+ Environment* env = Environment::GetCurrent (isolate-> GetCurrentContext () );
207
204
if (env == nullptr ) return -1 ;
208
205
return env->trigger_async_id ();
209
206
}
210
207
211
-
212
208
async_context EmitAsyncInit (Isolate* isolate,
213
209
Local<Object> resource,
214
210
const char * name,
@@ -225,7 +221,7 @@ async_context EmitAsyncInit(Isolate* isolate,
225
221
Local<String> name,
226
222
async_id trigger_async_id) {
227
223
DebugSealHandleScope handle_scope (isolate);
228
- Environment* env = Environment::GetCurrent (isolate);
224
+ Environment* env = Environment::GetCurrent (isolate-> GetCurrentContext () );
229
225
CHECK_NOT_NULL (env);
230
226
231
227
// Initialize async context struct
@@ -245,7 +241,8 @@ async_context EmitAsyncInit(Isolate* isolate,
245
241
}
246
242
247
243
void EmitAsyncDestroy (Isolate* isolate, async_context asyncContext) {
248
- EmitAsyncDestroy (Environment::GetCurrent (isolate), asyncContext);
244
+ EmitAsyncDestroy (Environment::GetCurrent (isolate->GetCurrentContext ()),
245
+ asyncContext);
249
246
}
250
247
251
248
void EmitAsyncDestroy (Environment* env, async_context asyncContext) {
0 commit comments