summaryrefslogtreecommitdiff
path: root/libqdutils
diff options
context:
space:
mode:
authorPrabhanjan Kandula <pkandula@codeaurora.org>2013-07-09 15:41:08 +0530
committerPrabhanjan Kandula <pkandula@codeaurora.org>2013-07-11 14:46:15 +0530
commit04167cb639da2fed27f9f56e12b14d32375cab51 (patch)
tree36304e5751bd3d5dec99d2d89d95de219e479d67 /libqdutils
parent86743b9ab8d9eb9181c3ad499c1e2fe9337273ca (diff)
downloaddisplay-04167cb639da2fed27f9f56e12b14d32375cab51.tar.gz
libqdutils: Add synchronization to idle invalidator
Protect invalidator data from accessing multiple threads asynchronously. Composition thread and idle invalidator threads could access at same time. Add locking to protect invalidator class member variables. Change-Id: I568ec367958c88f70f7aa4e6917abd53830adfd3
Diffstat (limited to 'libqdutils')
-rw-r--r--libqdutils/idle_invalidator.cpp4
-rw-r--r--libqdutils/idle_invalidator.h2
2 files changed, 6 insertions, 0 deletions
diff --git a/libqdutils/idle_invalidator.cpp b/libqdutils/idle_invalidator.cpp
index 4f039681..97176a41 100644
--- a/libqdutils/idle_invalidator.cpp
+++ b/libqdutils/idle_invalidator.cpp
@@ -45,6 +45,7 @@ int IdleInvalidator::init(InvalidatorHandler reg_handler, void* user_data,
unsigned int idleSleepTime) {
ALOGD_IF(II_DEBUG, "%s", __func__);
+ Locker::Autolock _l(mLock);
/* store registered handler */
mHandler = reg_handler;
mHwcContext = user_data;
@@ -55,6 +56,8 @@ int IdleInvalidator::init(InvalidatorHandler reg_handler, void* user_data,
bool IdleInvalidator::threadLoop() {
ALOGD_IF(II_DEBUG, "%s", __func__);
usleep(mSleepTime * 500);
+
+ Locker::Autolock _l(mLock);
if(mSleepAgain) {
//We need to sleep again!
mSleepAgain = false;
@@ -75,6 +78,7 @@ void IdleInvalidator::onFirstRef() {
}
void IdleInvalidator::markForSleep() {
+ Locker::Autolock _l(mLock);
mSleepAgain = true;
//Triggers the threadLoop to run, if not already running.
run(threadName, android::PRIORITY_AUDIO);
diff --git a/libqdutils/idle_invalidator.h b/libqdutils/idle_invalidator.h
index 82b1ac0c..abd9b29b 100644
--- a/libqdutils/idle_invalidator.h
+++ b/libqdutils/idle_invalidator.h
@@ -32,6 +32,7 @@
#include <cutils/log.h>
#include <utils/threads.h>
+#include <gr.h>
typedef void (*InvalidatorHandler)(void*);
@@ -41,6 +42,7 @@ class IdleInvalidator : public android::Thread {
unsigned int mSleepTime;
static InvalidatorHandler mHandler;
static android::sp<IdleInvalidator> sInstance;
+ mutable Locker mLock;
public:
IdleInvalidator();