GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — node/src/api/hooks.cc at master · basti1302/node Expand file tree/ Copy pathhooks.ccMore file actions 142 lines (118 loc) · 4.23 KB / Copy pathhooks.ccFile metadata and controls142 lines (118 loc) · 4.23 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 #include "env-inl.h" #include "node_internals.h" #include "node_process.h" #include "async_wrap.h" namespace node { using v8::Context; using v8::HandleScope; using v8::Integer; using v8::Isolate; using v8::Local; using v8::Object; using v8::String; using v8::Value; using v8::NewStringType; void RunAtExit(Environment* env) { env->RunAtExitCallbacks(); } void AtExit(void (*cb)(void* arg), void* arg) { auto env = Environment::GetThreadLocalEnv(); AtExit(env, cb, arg); } void AtExit(Environment* env, void (*cb)(void* arg), void* arg) { CHECK_NOT_NULL(env); env->AtExit(cb, arg); } void EmitBeforeExit(Environment* env) { env->RunBeforeExitCallbacks(); HandleScope handle_scope(env->isolate()); Context::Scope context_scope(env->context()); Local<Value> exit_code = env->process_object() ->Get(env->context(), env->exit_code_string()) .ToLocalChecked() ->ToInteger(env->context()) .ToLocalChecked(); ProcessEmit(env, "beforeExit", exit_code).ToLocalChecked(); } int EmitExit(Environment* env) { // process.emit('exit') HandleScope handle_scope(env->isolate()); Context::Scope context_scope(env->context()); Local<Object> process_object = env->process_object(); process_object ->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), "_exiting"), True(env->isolate())) .Check(); Local<String> exit_code = env->exit_code_string(); int code = process_object->Get(env->context(), exit_code) .ToLocalChecked() ->Int32Value(env->context()) .ToChecked(); ProcessEmit(env, "exit", Integer::New(env->isolate(), code)); // Reload exit code, it may be changed by `emit('exit')` return process_object->Get(env->context(), exit_code) .ToLocalChecked() ->Int32Value(env->context()) .ToChecked(); } void AddEnvironmentCleanupHook(Isolate* isolate, void (*fun)(void* arg), void* arg) { Environment* env = Environment::GetCurrent(isolate); CHECK_NOT_NULL(env); env->AddCleanupHook(fun, arg); } void RemoveEnvironmentCleanupHook(Isolate* isolate, void (*fun)(void* arg), void* arg) { Environment* env = Environment::GetCurrent(isolate); CHECK_NOT_NULL(env); env->RemoveCleanupHook(fun, arg); } async_id AsyncHooksGetExecutionAsyncId(Isolate* isolate) { Environment* env = Environment::GetCurrent(isolate); if (env == nullptr) return -1; return env->execution_async_id(); } async_id AsyncHooksGetTriggerAsyncId(Isolate* isolate) { Environment* env = Environment::GetCurrent(isolate); if (env == nullptr) return -1; return env->trigger_async_id(); } async_context EmitAsyncInit(Isolate* isolate, Local<Object> resource, const char* name, async_id trigger_async_id) { HandleScope handle_scope(isolate); Local<String> type = String::NewFromUtf8(isolate, name, NewStringType::kInternalized) .ToLocalChecked(); return EmitAsyncInit(isolate, resource, type, trigger_async_id); } async_context EmitAsyncInit(Isolate* isolate, Local<Object> resource, Local<String> name, async_id trigger_async_id) { DebugSealHandleScope handle_scope(isolate); Environment* env = Environment::GetCurrent(isolate); CHECK_NOT_NULL(env); // Initialize async context struct if (trigger_async_id == -1) trigger_async_id = env->get_default_trigger_async_id(); async_context context = { env->new_async_id(), // async_id_ trigger_async_id // trigger_async_id_ }; // Run init hooks AsyncWrap::EmitAsyncInit(env, resource, name, context.async_id, context.trigger_async_id); return context; } void EmitAsyncDestroy(Isolate* isolate, async_context asyncContext) { EmitAsyncDestroy(Environment::GetCurrent(isolate), asyncContext); } void EmitAsyncDestroy(Environment* env, async_context asyncContext) { AsyncWrap::EmitDestroy(env, asyncContext.async_id); } } // namespace node |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |