diff --git a/indra/llcommon/threadpool.cpp b/indra/llcommon/threadpool.cpp index d5adf11264cfc25f8de690f545a2a80807355c50..22bbff447872c3f264d41f0274527339e45eb433 100644 --- a/indra/llcommon/threadpool.cpp +++ b/indra/llcommon/threadpool.cpp @@ -21,11 +21,12 @@ #include "llevents.h" #include "stringize.h" -LL::ThreadPool::ThreadPool(const std::string& name, size_t threads, size_t capacity): +LL::ThreadPool::ThreadPool(const std::string& name, size_t threads, size_t capacity, bool auto_shutdown): super(name), mQueue(name, capacity), mName("ThreadPool:" + name), - mThreadCount(threads) + mThreadCount(threads), + mAutomaticShutdown(auto_shutdown) {} void LL::ThreadPool::start() @@ -39,6 +40,13 @@ void LL::ThreadPool::start() run(tname); }); } + + // Some threads might need to run longer than LLEventPumps + if (!mAutomaticShutdown) + { + return; + } + // Listen on "LLApp", and when the app is shutting down, close the queue // and join the workers. LLEventPumps::instance().obtain("LLApp").listen( diff --git a/indra/llcommon/threadpool.h b/indra/llcommon/threadpool.h index f8eec3b45744d8a18532811a24901fe84271f62a..22c875edb94d8202f5113096c12d8f172d0c8f35 100644 --- a/indra/llcommon/threadpool.h +++ b/indra/llcommon/threadpool.h @@ -31,7 +31,7 @@ namespace LL * Pass ThreadPool a string name. This can be used to look up the * relevant WorkQueue. */ - ThreadPool(const std::string& name, size_t threads=1, size_t capacity=1024); + ThreadPool(const std::string& name, size_t threads=1, size_t capacity=1024, bool auto_shutdown = true); virtual ~ThreadPool(); /** @@ -66,6 +66,7 @@ namespace LL std::string mName; size_t mThreadCount; std::vector<std::pair<std::string, std::thread>> mThreads; + bool mAutomaticShutdown; }; } // namespace LL diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 2e560ddb0a6ae8727deb497cd6d16dae3111c076..01e38fcc9ddfeb1c95c379c62db0a1985acffe57 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -828,6 +828,7 @@ void LLWindowWin32::close() // Is window is already closed? if (!mWindowHandle) { + mWindowThread->close(); return; } @@ -4590,7 +4591,7 @@ std::vector<std::string> LLWindowWin32::getDynamicFallbackFontList() #endif // LL_WINDOWS inline LLWindowWin32::LLWindowWin32Thread::LLWindowWin32Thread() - : ThreadPool("Window Thread", 1, MAX_QUEUE_SIZE) + : ThreadPool("Window Thread", 1, MAX_QUEUE_SIZE, false) { ThreadPool::start(); }