Revert "Revert "Fix lifecycle issue in CommonPool""
This reverts commit 162305aaceca5f6cbaa03db1aa124f67e313612e.
Adjusted tests to ensure they pass on cf_x86
Bug: 129250875
Test: this on cf_x86 & blueline
Change-Id: Ic3245ec8db784ae356b7fa66dda9a2fc91c622ea
diff --git a/libs/hwui/thread/CommonPool.cpp b/libs/hwui/thread/CommonPool.cpp
index 7f94a15..d011bdf 100644
--- a/libs/hwui/thread/CommonPool.cpp
+++ b/libs/hwui/thread/CommonPool.cpp
@@ -49,9 +49,13 @@
}
}
-void CommonPool::post(Task&& task) {
+CommonPool& CommonPool::instance() {
static CommonPool pool;
- pool.enqueue(std::move(task));
+ return pool;
+}
+
+void CommonPool::post(Task&& task) {
+ instance().enqueue(std::move(task));
}
void CommonPool::enqueue(Task&& task) {
@@ -86,5 +90,18 @@
}
}
+void CommonPool::waitForIdle() {
+ instance().doWaitForIdle();
+}
+
+void CommonPool::doWaitForIdle() {
+ std::unique_lock lock(mLock);
+ while (mWaitingThreads != THREAD_COUNT) {
+ lock.unlock();
+ usleep(100);
+ lock.lock();
+ }
+}
+
} // namespace uirenderer
} // namespace android
\ No newline at end of file