diff --git a/hecl/include/hecl/ClientProcess.hpp b/hecl/include/hecl/ClientProcess.hpp index be9a6f62c..bd05071e4 100644 --- a/hecl/include/hecl/ClientProcess.hpp +++ b/hecl/include/hecl/ClientProcess.hpp @@ -16,6 +16,7 @@ class ClientProcess { std::mutex m_mutex; std::condition_variable m_cv; + std::condition_variable m_initCv; int m_verbosity; public: @@ -71,6 +72,7 @@ private: ClientProcess& m_proc; std::thread m_thr; BlenderToken m_blendTok; + bool m_didInit = false; Worker(ClientProcess& proc); void proc(); }; diff --git a/hecl/lib/ClientProcess.cpp b/hecl/lib/ClientProcess.cpp index a157b8170..69d1358c2 100644 --- a/hecl/lib/ClientProcess.cpp +++ b/hecl/lib/ClientProcess.cpp @@ -63,6 +63,11 @@ void ClientProcess::Worker::proc() while (m_proc.m_running) { std::unique_lock lk(m_proc.m_mutex); + if (!m_didInit) + { + m_proc.m_initCv.notify_one(); + m_didInit = true; + } while (m_proc.m_pendingQueue.size()) { std::unique_ptr trans = std::move(m_proc.m_pendingQueue.front()); @@ -89,7 +94,11 @@ ClientProcess::ClientProcess(int verbosityLevel) #endif m_workers.reserve(cpuCount); for (int i=0 ; i lk(m_mutex); m_workers.emplace_back(*this); + m_initCv.wait(lk); + } } const ClientProcess::BufferTransaction*