summaryrefslogtreecommitdiff
path: root/hwc3/Composer.cpp
diff options
context:
space:
mode:
authorLong Ling <longling@google.com>2022-02-15 19:55:48 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2022-02-15 19:55:48 +0000
commitf81f10cb3e6eb0d941bf159c04a634df6cfbb1bf (patch)
tree5b367532f0da5aa3e8418042265dd5caeafd3abf /hwc3/Composer.cpp
parentb74e467e683801894726c563535e937f0bf62737 (diff)
parent292dc0bd2dc000513d02d60cbcad6574496f6fda (diff)
Merge "hwc3: do not check weak reference for client alive"
Diffstat (limited to 'hwc3/Composer.cpp')
-rw-r--r--hwc3/Composer.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/hwc3/Composer.cpp b/hwc3/Composer.cpp
index e3d714d..afd2602 100644
--- a/hwc3/Composer.cpp
+++ b/hwc3/Composer.cpp
@@ -42,7 +42,7 @@ ndk::ScopedAStatus Composer::createClient(std::shared_ptr<IComposerClient>* outC
auto clientDestroyed = [this]() { onClientDestroyed(); };
client->setOnClientDestroyed(clientDestroyed);
- mClient = client;
+ mClientAlive = true;
*outClient = client;
return ndk::ScopedAStatus::ok();
@@ -60,7 +60,7 @@ ndk::ScopedAStatus Composer::getCapabilities(std::vector<Capability>* caps) {
}
bool Composer::waitForClientDestroyedLocked(std::unique_lock<std::mutex>& lock) {
- if (!mClient.expired()) {
+ if (mClientAlive) {
using namespace std::chrono_literals;
// In surface flinger we delete a composer client on one thread and
@@ -71,18 +71,18 @@ bool Composer::waitForClientDestroyedLocked(std::unique_lock<std::mutex>& lock)
// see if the existing client is destroyed.
LOG(DEBUG) << "waiting for previous client to be destroyed";
mClientDestroyedCondition.wait_for(lock, 1s,
- [this]() -> bool { return mClient.expired(); });
- if (!mClient.expired()) {
+ [this]() -> bool { return !mClientAlive; });
+ if (mClientAlive) {
LOG(DEBUG) << "previous client was not destroyed";
}
}
- return mClient.expired() ;
+ return !mClientAlive;
}
void Composer::onClientDestroyed() {
std::lock_guard<std::mutex> lock(mClientMutex);
- mClient.reset();
+ mClientAlive = false;
mClientDestroyedCondition.notify_all();
}