Skip to content

Commit 1584afc

Browse files
committed
simplify
1 parent 9c52907 commit 1584afc

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

src/env.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,15 +1411,16 @@ void Environment::RunAndClearInterrupts() {
14111411
}
14121412
}
14131413

1414+
bool Environment::HasNativeImmediates() const {
1415+
return native_immediates_.size() > 0 ||
1416+
native_immediates_threadsafe_.size() > 0 ||
1417+
native_immediates_interrupts_.size() > 0;
1418+
}
1419+
14141420
void Environment::RunAndClearNativeImmediates(bool only_refed) {
14151421
TRACE_EVENT0(TRACING_CATEGORY_NODE1(environment),
14161422
"RunAndClearNativeImmediates");
1417-
// Skip the callback scope on the common empty path. These are the only
1418-
// queues drained by this function. If a threadsafe immediate is queued
1419-
// concurrently after this check, uv_async_send() schedules another drain.
1420-
if (native_immediates_.size() == 0 &&
1421-
native_immediates_threadsafe_.size() == 0 &&
1422-
native_immediates_interrupts_.size() == 0) {
1423+
if (!HasNativeImmediates()) {
14231424
return;
14241425
}
14251426

@@ -1595,6 +1596,9 @@ void Environment::CheckImmediate(uv_check_t* handle) {
15951596
Environment* env = Environment::from_immediate_check_handle(handle);
15961597
TRACE_EVENT0(TRACING_CATEGORY_NODE1(environment), "CheckImmediate");
15971598

1599+
if (env->immediate_info()->count() == 0 && !env->HasNativeImmediates())
1600+
return;
1601+
15981602
HandleScope scope(env->isolate());
15991603
Context::Scope context_scope(env->context());
16001604

src/env.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,7 @@ class Environment final : public MemoryRetainer {
10341034

10351035
void RunAndClearNativeImmediates(bool only_refed = false);
10361036
void RunAndClearInterrupts();
1037+
bool HasNativeImmediates() const;
10371038

10381039
uv_buf_t allocate_managed_buffer(const size_t suggested_size);
10391040
std::unique_ptr<v8::BackingStore> release_managed_buffer(const uv_buf_t& buf);

0 commit comments

Comments
 (0)