镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/node_process_methods.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ using v8::HeapStatistics;
using v8::Integer;
using v8::Isolate;
using v8::Local;
using v8::LocalVector;
using v8::Maybe;
using v8::NewStringType;
using v8::Number;
Expand Down Expand Up @@ -289,7 +290,7 @@ static void Uptime(const FunctionCallbackInfo<Value>& args) {
static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);

std::vector<Local<Value>> request_v;
LocalVector<Value> request_v(env->isolate());
for (ReqWrapBase* req_wrap : *env->req_wrap_queue()) {
AsyncWrap* w = req_wrap->GetAsyncWrap();
if (w->persistent().IsEmpty())
Expand All @@ -306,7 +307,7 @@ static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {
void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);

std::vector<Local<Value>> handle_v;
LocalVector<Value> handle_v(env->isolate());
for (auto w : *env->handle_wrap_queue()) {
if (!HandleWrap::HasRef(w))
continue;
Expand All @@ -318,7 +319,7 @@ void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {

static void GetActiveResourcesInfo(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
std::vector<Local<Value>> resources_info;
LocalVector<Value> resources_info(env->isolate());

// Active requests
for (ReqWrapBase* req_wrap : *env->req_wrap_queue()) {
Expand All @@ -336,14 +337,17 @@ static void GetActiveResourcesInfo(const FunctionCallbackInfo<Value>& args) {
}

// Active timeouts
resources_info.insert(resources_info.end(),
env->timeout_info()[0],
FIXED_ONE_BYTE_STRING(env->isolate(), "Timeout"));
Local<Value> timeout_str = FIXED_ONE_BYTE_STRING(env->isolate(), "Timeout");
for (int i = 0; i < env->timeout_info()[0]; ++i) {
resources_info.push_back(timeout_str);
}

// Active immediates
resources_info.insert(resources_info.end(),
env->immediate_info()->ref_count(),
FIXED_ONE_BYTE_STRING(env->isolate(), "Immediate"));
Local<Value> immediate_str =
FIXED_ONE_BYTE_STRING(env->isolate(), "Immediate");
for (uint32_t i = 0; i < env->immediate_info()->ref_count(); ++i) {
resources_info.push_back(immediate_str);
}

args.GetReturnValue().Set(
Array::New(env->isolate(), resources_info.data(), resources_info.size()));
Expand Down