Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
......@@ -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() {
......
......@@ -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();
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment