Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Unified Diff: src/d8.cc

Issue 2752043002: [promises] Add %WaitForPromise runtime call to allow tests to reliably wait for promises to be fini… (Closed)
Patch Set: Don't touch runtime-promise.cc Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/isolate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 4ab7af6d2c7fedd22e61b098b0d2038285d0f3d2..8745d41027e61ead49916d78fc6cc0e8d99e3ae6 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -2585,12 +2585,23 @@ void Shell::CollectGarbage(Isolate* isolate) {
}
}
-
void Shell::EmptyMessageQueues(Isolate* isolate) {
- if (!i::FLAG_verify_predictable) {
- while (v8::platform::PumpMessageLoop(g_platform, isolate)) continue;
+ if (i::FLAG_verify_predictable) return;
+ while (true) {
+ // Pump the message loop until it is empty.
+ while (v8::platform::PumpMessageLoop(g_platform, isolate)) {
+ isolate->RunMicrotasks();
+ }
+ // Run the idle tasks.
v8::platform::RunIdleTasks(g_platform, isolate,
50.0 / base::Time::kMillisecondsPerSecond);
+ // If there are still outstanding waiters, sleep a little (to wait for
+ // background tasks) and then try everything again.
+ if (reinterpret_cast<i::Isolate*>(isolate)->GetWaitCountForTesting() > 0) {
+ base::OS::Sleep(base::TimeDelta::FromMilliseconds(1));
+ } else {
+ break;
+ }
}
}
« no previous file with comments | « no previous file | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698