Lines Matching +full:hook +full:- +full:run +full:- +full:in +full:- +full:context
1 #include "env-inl.h"
3 #include "node_process-inl.h"
8 using v8::Context;
22 env->RunAtExitCallbacks(); in RunAtExit()
32 env->AtExit(cb, arg); in AtExit()
42 if (!env->destroy_async_id_list()->empty()) in EmitProcessBeforeExit()
45 HandleScope handle_scope(env->isolate()); in EmitProcessBeforeExit()
46 Context::Scope context_scope(env->context()); in EmitProcessBeforeExit()
49 if (!env->process_object()->Get(env->context(), env->exit_code_string()) in EmitProcessBeforeExit()
53 if (!exit_code_v->ToInteger(env->context()).ToLocal(&exit_code)) { in EmitProcessBeforeExit()
67 HandleScope handle_scope(env->isolate()); in EmitProcessExit()
68 Context::Scope context_scope(env->context()); in EmitProcessExit()
69 Local<Object> process_object = env->process_object(); in EmitProcessExit()
76 ->Set(env->context(), in EmitProcessExit()
77 FIXED_ONE_BYTE_STRING(env->isolate(), "_exiting"), in EmitProcessExit()
78 True(env->isolate())).IsNothing()) return Nothing<int>(); in EmitProcessExit()
80 Local<String> exit_code = env->exit_code_string(); in EmitProcessExit()
83 if (!process_object->Get(env->context(), exit_code).ToLocal(&code_v) || in EmitProcessExit()
84 !code_v->Int32Value(env->context()).To(&code) || in EmitProcessExit()
85 ProcessEmit(env, "exit", Integer::New(env->isolate(), code)).IsEmpty() || in EmitProcessExit()
87 !process_object->Get(env->context(), exit_code).ToLocal(&code_v) || in EmitProcessExit()
88 !code_v->Int32Value(env->context()).To(&code)) { in EmitProcessExit()
103 // Use a self-reference to make sure the storage is kept alive while the
104 // cleanup hook is registered but not yet finished.
109 // (but not publicly so for easier ABI/API changes). In particular,
116 // default-initialize AsyncCleanupHookHandle, because in C++ for a
117 // std::unique_ptr to be default-initializable the deleter type also needs
118 // to be default-initializable; in particular, function types don't satisfy
127 env->AddCleanupHook(fun, arg); in AddEnvironmentCleanupHook()
135 env->RemoveCleanupHook(fun, arg); in RemoveEnvironmentCleanupHook()
140 std::shared_ptr<AsyncCleanupHookInfo> keep_alive = info->self; in FinishAsyncCleanupHook()
142 info->env->DecreaseWaitingRequestCounter(); in FinishAsyncCleanupHook()
143 info->self.reset(); in FinishAsyncCleanupHook()
148 info->env->IncreaseWaitingRequestCounter(); in RunAsyncCleanupHook()
149 info->started = true; in RunAsyncCleanupHook()
150 info->fun(info->arg, FinishAsyncCleanupHook, info); in RunAsyncCleanupHook()
160 info->env = env; in AddEnvironmentCleanupHook()
161 info->fun = fun; in AddEnvironmentCleanupHook()
162 info->arg = arg; in AddEnvironmentCleanupHook()
163 info->self = info; in AddEnvironmentCleanupHook()
164 env->AddCleanupHook(RunAsyncCleanupHook, info.get()); in AddEnvironmentCleanupHook()
170 if (handle->info->started) return; in RemoveEnvironmentCleanupHook()
171 handle->info->self.reset(); in RemoveEnvironmentCleanupHook()
172 handle->info->env->RemoveCleanupHook(RunAsyncCleanupHook, handle->info.get()); in RemoveEnvironmentCleanupHook()
177 if (env == nullptr) return -1; in AsyncHooksGetExecutionAsyncId()
178 return env->execution_async_id(); in AsyncHooksGetExecutionAsyncId()
183 if (env == nullptr) return -1; in AsyncHooksGetTriggerAsyncId()
184 return env->trigger_async_id(); in AsyncHooksGetTriggerAsyncId()
207 // Initialize async context struct in EmitAsyncInit()
208 if (trigger_async_id == -1) in EmitAsyncInit()
209 trigger_async_id = env->get_default_trigger_async_id(); in EmitAsyncInit()
211 async_context context = { in EmitAsyncInit() local
212 env->new_async_id(), // async_id_ in EmitAsyncInit()
216 // Run init hooks in EmitAsyncInit()
217 AsyncWrap::EmitAsyncInit(env, resource, name, context.async_id, in EmitAsyncInit()
218 context.trigger_async_id); in EmitAsyncInit()
220 return context; in EmitAsyncInit()