File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+
14141420void 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
Original file line number Diff line number Diff 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);
You can’t perform that action at this time.
0 commit comments