diff options
author | Erik Kundiman <erik@megapahit.org> | 2025-04-25 21:32:04 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2025-04-25 21:32:04 +0800 |
commit | b74c8ee3fee8dd640f40250ed09f213afa72cefc (patch) | |
tree | cdad4aa47d4c669292591154b9c3bc1851629dd6 /indra/llcommon/workqueue.cpp | |
parent | 0dd799f109760f00103a6c58b437aaf3148adc75 (diff) | |
parent | ec6c988bbbc59aed218d3629bf0c13192f6b726c (diff) |
Merge tag 'Second_Life_Release#ec6c988-2025.05' into 2025.052025.05
Diffstat (limited to 'indra/llcommon/workqueue.cpp')
-rw-r--r-- | indra/llcommon/workqueue.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/indra/llcommon/workqueue.cpp b/indra/llcommon/workqueue.cpp index 323903e59c..0eb20323ad 100644 --- a/indra/llcommon/workqueue.cpp +++ b/indra/llcommon/workqueue.cpp @@ -21,6 +21,7 @@ #include "llcoros.h" #include LLCOROS_MUTEX_HEADER #include "llerror.h" +#include "llevents.h" #include "llexception.h" #include "stringize.h" @@ -34,10 +35,34 @@ LL::WorkQueueBase::WorkQueueBase(const std::string& name, bool auto_shutdown) : super(makeName(name)) { if (auto_shutdown) -{ - // TODO: register for "LLApp" events so we can implicitly close() on - // viewer shutdown. + { + // Register for "LLApp" events so we can implicitly close() on viewer shutdown + std::string listener_name = "WorkQueue:" + getKey(); + LLEventPumps::instance().obtain("LLApp").listen( + listener_name, + [this](const LLSD& stat) + { + std::string status(stat["status"]); + if (status != "running") + { + // Viewer is shutting down, close this queue + LL_DEBUGS("WorkQueue") << getKey() << " closing on app shutdown" << LL_ENDL; + close(); + } + return false; + }); + + // Store the listener name so we can unregister in the destructor + mListenerName = listener_name; + } } + +LL::WorkQueueBase::~WorkQueueBase() +{ + if (!mListenerName.empty() && !LLEventPumps::wasDeleted()) + { + LLEventPumps::instance().obtain("LLApp").stopListening(mListenerName); + } } void LL::WorkQueueBase::runUntilClose() |