Add callback for notifying that startup is completed
Add a callback that can be called to denote that application startup
is completed. This may affect how the profile is collected and how
startup related caches are managed.
Bug: 123377072
Bug: 120671223
Test: test-art-host
Change-Id: If7eb8909cc5e99082a2243b5029380244b46174d
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index aa35780..6ab5d98 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -2773,4 +2773,21 @@
}
}
+void Runtime::NotifyStartupCompleted() {
+ bool expected = false;
+ if (!startup_completed_.compare_exchange_strong(expected, true, std::memory_order_seq_cst)) {
+ // Right now NotifyStartupCompleted will be called up to twice, once from profiler and up to
+ // once externally. For this reason there are no asserts.
+ return;
+ }
+ VLOG(startup) << "Startup completed notified";
+
+ // Notify the profiler saver that startup is now completed.
+ ProfileSaver::NotifyStartupCompleted();
+}
+
+bool Runtime::GetStartupCompleted() const {
+ return startup_completed_.load(std::memory_order_seq_cst);
+}
+
} // namespace art