SF: Set up libscheduler and libscheduler_test
Fix up dependencies to migrate Timer files for starters.
Bug: 185535769
Test: libscheduler_test
Change-Id: I028cb04f2e355e2096be9efe3c1a80f0dfd75602
diff --git a/services/surfaceflinger/Scheduler/VSyncDispatchTimerQueue.h b/services/surfaceflinger/Scheduler/VSyncDispatchTimerQueue.h
index 76e1caf..3186d6d 100644
--- a/services/surfaceflinger/Scheduler/VSyncDispatchTimerQueue.h
+++ b/services/surfaceflinger/Scheduler/VSyncDispatchTimerQueue.h
@@ -16,7 +16,6 @@
#pragma once
-#include <android-base/thread_annotations.h>
#include <functional>
#include <memory>
#include <mutex>
@@ -24,10 +23,14 @@
#include <string_view>
#include <unordered_map>
+#include <android-base/thread_annotations.h>
+
#include "VSyncDispatch.h"
namespace android::scheduler {
+class VSyncTracker;
+
// VSyncDispatchTimerQueueEntry is a helper class representing internal state for each entry in
// VSyncDispatchTimerQueue hoisted to public for unit testing.
class VSyncDispatchTimerQueueEntry {
@@ -36,7 +39,7 @@
// Valid transition: disarmed -> armed ( when scheduled )
// Valid transition: armed -> running -> disarmed ( when timer is called)
// Valid transition: armed -> disarmed ( when cancelled )
- VSyncDispatchTimerQueueEntry(std::string const& name, VSyncDispatch::Callback const& fn,
+ VSyncDispatchTimerQueueEntry(std::string name, VSyncDispatch::Callback,
nsecs_t minVsyncDistance);
std::string_view name() const;
@@ -45,10 +48,9 @@
std::optional<nsecs_t> lastExecutedVsyncTarget() const;
// This moves the state from disarmed->armed and will calculate the wakeupTime.
- ScheduleResult schedule(VSyncDispatch::ScheduleTiming timing, VSyncTracker& tracker,
- nsecs_t now);
+ ScheduleResult schedule(VSyncDispatch::ScheduleTiming, VSyncTracker&, nsecs_t now);
// This will update armed entries with the latest vsync information. Entry remains armed.
- void update(VSyncTracker& tracker, nsecs_t now);
+ void update(VSyncTracker&, nsecs_t now);
// This will return empty if not armed, or the next calculated wakeup time if armed.
// It will not update the wakeupTime.
@@ -81,11 +83,11 @@
void dump(std::string& result) const;
private:
- std::string const mName;
- VSyncDispatch::Callback const mCallback;
+ const std::string mName;
+ const VSyncDispatch::Callback mCallback;
VSyncDispatch::ScheduleTiming mScheduleTiming;
- nsecs_t const mMinVsyncDistance;
+ const nsecs_t mMinVsyncDistance;
struct ArmingInfo {
nsecs_t mActualWakeupTime;
@@ -115,19 +117,19 @@
// should be grouped into one wakeup.
// \param[in] minVsyncDistance The minimum distance between two vsync estimates before the
// vsyncs are considered the same vsync event.
- explicit VSyncDispatchTimerQueue(std::unique_ptr<TimeKeeper> tk, VSyncTracker& tracker,
- nsecs_t timerSlack, nsecs_t minVsyncDistance);
+ VSyncDispatchTimerQueue(std::unique_ptr<TimeKeeper>, VSyncTracker&, nsecs_t timerSlack,
+ nsecs_t minVsyncDistance);
~VSyncDispatchTimerQueue();
- CallbackToken registerCallback(Callback const& callbackFn, std::string callbackName) final;
- void unregisterCallback(CallbackToken token) final;
- ScheduleResult schedule(CallbackToken token, ScheduleTiming scheduleTiming) final;
- CancelResult cancel(CallbackToken token) final;
- void dump(std::string& result) const final;
+ CallbackToken registerCallback(Callback, std::string callbackName) final;
+ void unregisterCallback(CallbackToken) final;
+ ScheduleResult schedule(CallbackToken, ScheduleTiming) final;
+ CancelResult cancel(CallbackToken) final;
+ void dump(std::string&) const final;
private:
- VSyncDispatchTimerQueue(VSyncDispatchTimerQueue const&) = delete;
- VSyncDispatchTimerQueue& operator=(VSyncDispatchTimerQueue const&) = delete;
+ VSyncDispatchTimerQueue(const VSyncDispatchTimerQueue&) = delete;
+ VSyncDispatchTimerQueue& operator=(const VSyncDispatchTimerQueue&) = delete;
using CallbackMap =
std::unordered_map<CallbackToken, std::shared_ptr<VSyncDispatchTimerQueueEntry>>;