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-15 22:20:06 +0300
committerShelley Vohr <shelley.vohr@gmail.com>2020-02-17 21:53:58 +0300
commit74a7cdbe05feee981eabfa13675a14a49773adff (patch)
tree2f5485d99ec30a079f22c906426acc69c2876d8f /src/env.cc
parent53e566bc50a8624394ff255059f4b6b2b3305068 (diff)
src: exclude C++ SetImmediate() from count
There is no real reason to manage a count manually, given that checking whether there are C++ callbacks is a single pointer comparison. This makes it easier to add other kinds of native C++ callbacks that are managed in a similar way. PR-URL: https://github.com/nodejs/node/pull/31386 Refs: https://github.com/openjs-foundation/summit/pull/240 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/env.cc')
-rw-r--r--src/env.cc12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/env.cc b/src/env.cc
index a4defc2528c..b77d4f294d0 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -665,7 +665,6 @@ void Environment::RunAndClearNativeImmediates(bool only_refed) {
TraceEventScope trace_scope(TRACING_CATEGORY_NODE1(environment),
"RunAndClearNativeImmediates", this);
size_t ref_count = 0;
- size_t count = 0;
NativeImmediateQueue queue;
queue.ConcatMove(std::move(native_immediates_));
@@ -674,7 +673,6 @@ void Environment::RunAndClearNativeImmediates(bool only_refed) {
TryCatchScope try_catch(this);
DebugSealHandleScope seal_handle_scope(isolate());
while (std::unique_ptr<NativeImmediateCallback> head = queue.Shift()) {
- count++;
if (head->is_refed())
ref_count++;
@@ -692,9 +690,10 @@ void Environment::RunAndClearNativeImmediates(bool only_refed) {
};
while (queue.size() > 0 && drain_list()) {}
- DCHECK_GE(immediate_info()->count(), count);
- immediate_info()->count_dec(count);
immediate_info()->ref_count_dec(ref_count);
+
+ if (immediate_info()->ref_count() == 0)
+ ToggleImmediateRef(false);
}
@@ -780,15 +779,12 @@ void Environment::CheckImmediate(uv_check_t* handle) {
TraceEventScope trace_scope(TRACING_CATEGORY_NODE1(environment),
"CheckImmediate", env);
- if (env->immediate_info()->count() == 0)
- return;
-
HandleScope scope(env->isolate());
Context::Scope context_scope(env->context());
env->RunAndClearNativeImmediates();
- if (!env->can_call_into_js())
+ if (env->immediate_info()->count() == 0 || !env->can_call_into_js())
return;
do {