Skip to content

Commit 41f333e

Browse files
committed
src,http_parser: remove KickNextTick call
Now that HTTPParser uses MakeCallback it is unnecessary to manually process the nextTickQueue. The KickNextTick function is now no longer needed so code has moved back to node::MakeCallback to simplify implementation. Include minor cleanup moving Environment::tick_info() call below the early return to save an operation. PR-URL: nodejs#5756 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
1 parent 4bc1ccc commit 41f333e

5 files changed

Lines changed: 21 additions & 33 deletions

File tree

src/async-wrap.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ Local<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
181181
Local<Function> post_fn = env()->async_hooks_post_function();
182182
Local<Value> uid = Integer::New(env()->isolate(), get_uid());
183183
Local<Object> context = object();
184-
Local<Object> process = env()->process_object();
185184
Local<Object> domain;
186185
bool has_domain = false;
187186

@@ -233,16 +232,18 @@ Local<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
233232
}
234233
}
235234

236-
Environment::TickInfo* tick_info = env()->tick_info();
237-
238235
if (callback_scope.in_makecallback()) {
239236
return ret;
240237
}
241238

239+
Environment::TickInfo* tick_info = env()->tick_info();
240+
242241
if (tick_info->length() == 0) {
243242
env()->isolate()->RunMicrotasks();
244243
}
245244

245+
Local<Object> process = env()->process_object();
246+
246247
if (tick_info->length() == 0) {
247248
tick_info->set_index(0);
248249
return ret;

src/env.cc

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,4 @@ void Environment::PrintSyncTrace() const {
6464
fflush(stderr);
6565
}
6666

67-
68-
bool Environment::KickNextTick(Environment::AsyncCallbackScope* scope) {
69-
TickInfo* info = tick_info();
70-
71-
if (scope->in_makecallback()) {
72-
return true;
73-
}
74-
75-
if (info->length() == 0) {
76-
isolate()->RunMicrotasks();
77-
}
78-
79-
if (info->length() == 0) {
80-
info->set_index(0);
81-
return true;
82-
}
83-
84-
Local<Value> ret =
85-
tick_callback_function()->Call(process_object(), 0, nullptr);
86-
87-
return !ret.IsEmpty();
88-
}
89-
9067
} // namespace node

src/env.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,6 @@ class Environment {
475475

476476
inline int64_t get_async_wrap_uid();
477477

478-
bool KickNextTick(AsyncCallbackScope* scope);
479-
480478
inline uint32_t* heap_statistics_buffer() const;
481479
inline void set_heap_statistics_buffer(uint32_t* pointer);
482480

src/node.cc

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,23 @@ Local<Value> MakeCallback(Environment* env,
12221222
}
12231223
}
12241224

1225-
if (!env->KickNextTick(&callback_scope)) {
1225+
if (callback_scope.in_makecallback()) {
1226+
return ret;
1227+
}
1228+
1229+
Environment::TickInfo* tick_info = env->tick_info();
1230+
1231+
if (tick_info->length() == 0) {
1232+
env->isolate()->RunMicrotasks();
1233+
}
1234+
1235+
Local<Object> process = env->process_object();
1236+
1237+
if (tick_info->length() == 0) {
1238+
tick_info->set_index(0);
1239+
}
1240+
1241+
if (env->tick_callback_function()->Call(process, 0, nullptr).IsEmpty()) {
12261242
return Undefined(env->isolate());
12271243
}
12281244

src/node_http_parser.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,6 @@ class Parser : public AsyncWrap {
587587
if (!cb->IsFunction())
588588
return;
589589

590-
Environment::AsyncCallbackScope callback_scope(parser->env());
591-
592590
// Hooks for GetCurrentBuffer
593591
parser->current_buffer_len_ = nread;
594592
parser->current_buffer_data_ = buf->base;
@@ -597,8 +595,6 @@ class Parser : public AsyncWrap {
597595

598596
parser->current_buffer_len_ = 0;
599597
parser->current_buffer_data_ = nullptr;
600-
601-
parser->env()->KickNextTick(&callback_scope);
602598
}
603599

604600

0 commit comments

Comments
 (0)