Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2020-01-25 04:02:57 +0300
committerShelley Vohr <shelley.vohr@gmail.com>2020-02-17 22:37:04 +0300
commitef4d0816601a329928f244de5e1702c6dd78b692 (patch)
treee5a8b643b9a499456ffd448a4ee40769ef541b33 /src/env.cc
parent07525c317e8b5d3135e738c10b695dac638b6966 (diff)
src: simplify native immediate queue running
Make `SetImmediate()` behave more like `process.nextTick()` (which matches how we use it) by also running tasks that have been added during previous `SetImmediate()` calls. PR-URL: https://github.com/nodejs/node/pull/31502 Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Diffstat (limited to 'src/env.cc')
-rw-r--r--src/env.cc8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/env.cc b/src/env.cc
index 869a28af03b..b6ad131f521 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -688,13 +688,11 @@ void Environment::RunAndClearNativeImmediates(bool only_refed) {
native_immediates_.ConcatMove(std::move(native_immediates_threadsafe_));
}
- NativeImmediateQueue queue;
- queue.ConcatMove(std::move(native_immediates_));
-
auto drain_list = [&]() {
TryCatchScope try_catch(this);
DebugSealHandleScope seal_handle_scope(isolate());
- while (std::unique_ptr<NativeImmediateCallback> head = queue.Shift()) {
+ while (std::unique_ptr<NativeImmediateCallback> head =
+ native_immediates_.Shift()) {
if (head->is_refed())
ref_count++;
@@ -712,7 +710,7 @@ void Environment::RunAndClearNativeImmediates(bool only_refed) {
}
return false;
};
- while (queue.size() > 0 && drain_list()) {}
+ while (drain_list()) {}
immediate_info()->ref_count_dec(ref_count);