Skip to content

Commit

Permalink
core, refactor: PumpMessageLoop only when there are background tasks.
Browse files Browse the repository at this point in the history
  • Loading branch information
xicilion committed Mar 6, 2023
1 parent 3188324 commit 971acea
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions fibjs/src/base/Isolate.cpp
Expand Up @@ -35,11 +35,12 @@ static int32_t syncRunMicrotasks(Isolate* isolate)
JSFiber::EnterJsScope s(NULL, true);

isolate->m_isolate->PerformMicrotaskCheckpoint();
while (v8::platform::PumpMessageLoop(g_default_platform, isolate->m_isolate,
isolate->m_isolate->HasPendingBackgroundTasks()
? v8::platform::MessageLoopBehavior::kWaitForWork
: platform::MessageLoopBehavior::kDoNotWait))
;
if (isolate->m_isolate->HasPendingBackgroundTasks())
while (v8::platform::PumpMessageLoop(g_default_platform, isolate->m_isolate,
isolate->m_isolate->HasPendingBackgroundTasks()
? v8::platform::MessageLoopBehavior::kWaitForWork
: platform::MessageLoopBehavior::kDoNotWait))
;

return 0;
}
Expand Down

0 comments on commit 971acea

Please sign in to comment.