diff options
author | 2018-06-08 15:11:57 -0700 | |
---|---|---|
committer | 2018-06-08 15:11:57 -0700 | |
commit | f11e2bd016d886a333345dea853ebda23a408d5c (patch) | |
tree | 905bd4d25d6ab2b046620ff459777d8dcfa5d7de /services/surfaceflinger/EventControlThread.h | |
parent | aabd6b7fa343654cd85b3b2da392e424d037d15a (diff) | |
parent | 5c947cdf72270fd1f766b2248d526ebc8c7227f6 (diff) |
Merge pi-dev-plus-aosp-without-vendor into stage-aosp-master
Bug: 79597307
Change-Id: I6d6bee71b9424eb478780bbfc06b830eb8ded342
Diffstat (limited to 'services/surfaceflinger/EventControlThread.h')
-rw-r--r-- | services/surfaceflinger/EventControlThread.h | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/services/surfaceflinger/EventControlThread.h b/services/surfaceflinger/EventControlThread.h index 1b1ef75b9d..cafae53400 100644 --- a/services/surfaceflinger/EventControlThread.h +++ b/services/surfaceflinger/EventControlThread.h @@ -14,35 +14,50 @@ * limitations under the License. */ -#ifndef ANDROID_EVENTCONTROLTHREAD_H -#define ANDROID_EVENTCONTROLTHREAD_H +#pragma once -#include <stddef.h> +#include <condition_variable> +#include <cstddef> +#include <functional> +#include <mutex> +#include <thread> -#include <utils/Mutex.h> -#include <utils/Thread.h> +#include <android-base/thread_annotations.h> namespace android { -class SurfaceFlinger; +class EventControlThread { +public: + virtual ~EventControlThread(); + + virtual void setVsyncEnabled(bool enabled) = 0; +}; + +namespace impl { -class EventControlThread: public Thread { +class EventControlThread final : public android::EventControlThread { public: + using SetVSyncEnabledFunction = std::function<void(bool)>; - explicit EventControlThread(const sp<SurfaceFlinger>& flinger); - virtual ~EventControlThread() {} + explicit EventControlThread(SetVSyncEnabledFunction function); + ~EventControlThread(); - void setVsyncEnabled(bool enabled); - virtual bool threadLoop(); + // EventControlThread implementation + void setVsyncEnabled(bool enabled) override; private: - sp<SurfaceFlinger> mFlinger; - bool mVsyncEnabled; + void threadMain(); - Mutex mMutex; - Condition mCond; -}; + std::mutex mMutex; + std::condition_variable mCondition; + + const SetVSyncEnabledFunction mSetVSyncEnabled; + bool mVsyncEnabled GUARDED_BY(mMutex) = false; + bool mKeepRunning GUARDED_BY(mMutex) = true; -} + // Must be last so that everything is initialized before the thread starts. + std::thread mThread{&EventControlThread::threadMain, this}; +}; -#endif // ANDROID_EVENTCONTROLTHREAD_H +} // namespace impl +} // namespace android |