drm_hwcomposer: Clean up VsyncWorker destruction

With VsyncWorker no longer acquiring the main lock, we can use
std::thread::join on the main thread to ensure that the vsync thread is
stopped cleanly in the VSyncWorker destructor.

- Don't pass a shared_ptr<> into VSyncWorker::ThreadFn to simplify
  lifetime management
- Change to unique_ptr to simplify lifetime management
- Remove the hack to destroy the HwcDisplays in two stages when
  destructing ComposerClient
- Add std::thread::join to VSyncWorker destructor

Change-Id: I25a34fd304c7b2ec48e43d538bf15794bdc9d68e
Signed-off-by: Drew Davenport <ddavenport@google.com>
diff --git a/drm/VSyncWorker.h b/drm/VSyncWorker.h
index 0809f48..c76dd14 100644
--- a/drm/VSyncWorker.h
+++ b/drm/VSyncWorker.h
@@ -31,10 +31,10 @@
   using VsyncTimestampCallback = std::function<void(int64_t /*timestamp*/,
                                                     uint32_t /*period*/)>;
 
-  ~VSyncWorker() = default;
+  ~VSyncWorker();
 
   auto static CreateInstance(std::shared_ptr<DrmDisplayPipeline> &pipe)
-      -> std::shared_ptr<VSyncWorker>;
+      -> std::unique_ptr<VSyncWorker>;
 
   // Set the expected vsync period.
   void SetVsyncPeriodNs(uint32_t vsync_period_ns);
@@ -53,7 +53,7 @@
  private:
   VSyncWorker() = default;
 
-  void ThreadFn(const std::shared_ptr<VSyncWorker> &vsw);
+  void ThreadFn();
 
   int64_t GetPhasedVSync(int64_t frame_ns, int64_t current) const;
   int SyntheticWaitVBlank(int64_t *timestamp);