diff options
author | James M Snell <jasnell@gmail.com> | 2018-09-07 15:37:31 -0700 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-09-14 19:02:44 +0200 |
commit | efd4796fa905747985d6de215d5e64b4701cf347 (patch) | |
tree | 3176580ca525fc76f3973f47445f7797d5173fd4 | |
parent | 48e8918fd8aa837418590bebe5ff2efc335e4d1f (diff) | |
download | android-node-v8-efd4796fa905747985d6de215d5e64b4701cf347.tar.gz android-node-v8-efd4796fa905747985d6de215d5e64b4701cf347.tar.bz2 android-node-v8-efd4796fa905747985d6de215d5e64b4701cf347.zip |
src: move getActiveResources/Handles to node_process.cc
PR-URL: https://github.com/nodejs/node/pull/22758
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Refael Ackermann <refack@gmail.com>
-rw-r--r-- | src/node.cc | 55 | ||||
-rw-r--r-- | src/node_internals.h | 2 | ||||
-rw-r--r-- | src/node_process.cc | 55 |
3 files changed, 57 insertions, 55 deletions
diff --git a/src/node.cc b/src/node.cc index 72a83d538f..ed4da64425 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1040,61 +1040,6 @@ static MaybeLocal<Value> ExecuteString(Environment* env, } -static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) { - Environment* env = Environment::GetCurrent(args); - - Local<Array> ary = Array::New(args.GetIsolate()); - Local<Context> ctx = env->context(); - Local<Function> fn = env->push_values_to_array_function(); - Local<Value> argv[NODE_PUSH_VAL_TO_ARRAY_MAX]; - size_t idx = 0; - - for (auto w : *env->req_wrap_queue()) { - if (w->persistent().IsEmpty()) - continue; - argv[idx] = w->GetOwner(); - if (++idx >= arraysize(argv)) { - fn->Call(ctx, ary, idx, argv).ToLocalChecked(); - idx = 0; - } - } - - if (idx > 0) { - fn->Call(ctx, ary, idx, argv).ToLocalChecked(); - } - - args.GetReturnValue().Set(ary); -} - - -// Non-static, friend of HandleWrap. Could have been a HandleWrap method but -// implemented here for consistency with GetActiveRequests(). -void GetActiveHandles(const FunctionCallbackInfo<Value>& args) { - Environment* env = Environment::GetCurrent(args); - - Local<Array> ary = Array::New(env->isolate()); - Local<Context> ctx = env->context(); - Local<Function> fn = env->push_values_to_array_function(); - Local<Value> argv[NODE_PUSH_VAL_TO_ARRAY_MAX]; - size_t idx = 0; - - for (auto w : *env->handle_wrap_queue()) { - if (!HandleWrap::HasRef(w)) - continue; - argv[idx] = w->GetOwner(); - if (++idx >= arraysize(argv)) { - fn->Call(ctx, ary, idx, argv).ToLocalChecked(); - idx = 0; - } - } - if (idx > 0) { - fn->Call(ctx, ary, idx, argv).ToLocalChecked(); - } - - args.GetReturnValue().Set(ary); -} - - NO_RETURN void Abort() { DumpBacktrace(stderr); fflush(stderr); diff --git a/src/node_internals.h b/src/node_internals.h index 5cf606ddee..8ab79a1267 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -883,6 +883,8 @@ void Abort(const v8::FunctionCallbackInfo<v8::Value>& args); void Chdir(const v8::FunctionCallbackInfo<v8::Value>& args); void CPUUsage(const v8::FunctionCallbackInfo<v8::Value>& args); void Cwd(const v8::FunctionCallbackInfo<v8::Value>& args); +void GetActiveHandles(const v8::FunctionCallbackInfo<v8::Value>& args); +void GetActiveRequests(const v8::FunctionCallbackInfo<v8::Value>& args); void Hrtime(const v8::FunctionCallbackInfo<v8::Value>& args); void HrtimeBigInt(const v8::FunctionCallbackInfo<v8::Value>& args); void Kill(const v8::FunctionCallbackInfo<v8::Value>& args); diff --git a/src/node_process.cc b/src/node_process.cc index ba774fd8fa..19596f0cfd 100644 --- a/src/node_process.cc +++ b/src/node_process.cc @@ -1,5 +1,7 @@ #include "node.h" #include "node_internals.h" +#include "base_object.h" +#include "base_object-inl.h" #include "env-inl.h" #include "util-inl.h" #include "uv.h" @@ -786,5 +788,58 @@ void GetParentProcessId(Local<Name> property, info.GetReturnValue().Set(Integer::New(info.GetIsolate(), uv_os_getppid())); } +void GetActiveRequests(const FunctionCallbackInfo<Value>& args) { + Environment* env = Environment::GetCurrent(args); + + Local<Array> ary = Array::New(args.GetIsolate()); + Local<Context> ctx = env->context(); + Local<Function> fn = env->push_values_to_array_function(); + Local<Value> argv[NODE_PUSH_VAL_TO_ARRAY_MAX]; + size_t idx = 0; + + for (auto w : *env->req_wrap_queue()) { + if (w->persistent().IsEmpty()) + continue; + argv[idx] = w->GetOwner(); + if (++idx >= arraysize(argv)) { + fn->Call(ctx, ary, idx, argv).ToLocalChecked(); + idx = 0; + } + } + + if (idx > 0) { + fn->Call(ctx, ary, idx, argv).ToLocalChecked(); + } + + args.GetReturnValue().Set(ary); +} + + +// Non-static, friend of HandleWrap. Could have been a HandleWrap method but +// implemented here for consistency with GetActiveRequests(). +void GetActiveHandles(const FunctionCallbackInfo<Value>& args) { + Environment* env = Environment::GetCurrent(args); + + Local<Array> ary = Array::New(env->isolate()); + Local<Context> ctx = env->context(); + Local<Function> fn = env->push_values_to_array_function(); + Local<Value> argv[NODE_PUSH_VAL_TO_ARRAY_MAX]; + size_t idx = 0; + + for (auto w : *env->handle_wrap_queue()) { + if (!HandleWrap::HasRef(w)) + continue; + argv[idx] = w->GetOwner(); + if (++idx >= arraysize(argv)) { + fn->Call(ctx, ary, idx, argv).ToLocalChecked(); + idx = 0; + } + } + if (idx > 0) { + fn->Call(ctx, ary, idx, argv).ToLocalChecked(); + } + + args.GetReturnValue().Set(ary); +} } // namespace node |