Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1d708572 authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Android (Google) Code Review
Browse files

Merge "InputTracer: Ensure tracer thread is destructed first" into main

parents a11d3545 1cdb2fab
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -38,10 +38,10 @@ struct Visitor : V... {

template <typename Backend>
ThreadedBackend<Backend>::ThreadedBackend(Backend&& innerBackend)
      : mTracerThread(
      : mBackend(std::move(innerBackend)),
        mTracerThread(
                "InputTracer", [this]() { threadLoop(); },
                [this]() { mThreadWakeCondition.notify_all(); }),
        mBackend(std::move(innerBackend)) {}
                [this]() { mThreadWakeCondition.notify_all(); }) {}

template <typename Backend>
ThreadedBackend<Backend>::~ThreadedBackend() {
+5 −1
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ public:

private:
    std::mutex mLock;
    InputThread mTracerThread;
    bool mThreadExit GUARDED_BY(mLock){false};
    std::condition_variable mThreadWakeCondition;
    Backend mBackend;
@@ -53,6 +52,11 @@ private:
                      TracedEventArgs>;
    std::vector<TraceEntry> mQueue GUARDED_BY(mLock);

    // InputThread stops when its destructor is called. Initialize it last so that it is the
    // first thing to be destructed. This will guarantee the thread will not access other
    // members that have already been destructed.
    InputThread mTracerThread;

    void threadLoop();
};