commit 60202cc7d46cfd034ad17b15620bd14f2be2f08a
parent bf27e9c6324f6ce2b32e3e19a8fe65d8d8aa9b7b
Author: cfillion <cfillion@users.noreply.github.com>
Date: Sun, 23 Sep 2018 00:14:03 -0400
start the worker thread after everything it needs has been initialized [p=2037951]
Diffstat:
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/thread.cpp b/src/thread.cpp
@@ -83,7 +83,7 @@ void ThreadTask::exec()
ThreadNotifier::get()->notify({this, state});
};
-WorkerThread::WorkerThread() : m_thread(&WorkerThread::run, this), m_exit(false)
+WorkerThread::WorkerThread() : m_exit(false), m_thread(&WorkerThread::run, this)
{
}
diff --git a/src/thread.hpp b/src/thread.hpp
@@ -89,11 +89,12 @@ private:
void run();
ThreadTask *nextTask();
- std::thread m_thread;
- std::condition_variable m_wake;
std::mutex m_mutex;
std::atomic_bool m_exit;
+ std::condition_variable m_wake;
std::queue<ThreadTask *> m_queue;
+
+ std::thread m_thread;
};
class ThreadPool {