diff options
| author | Erik Kundiman <erik@megapahit.org> | 2025-09-09 14:23:24 +0800 | 
|---|---|---|
| committer | Erik Kundiman <erik@megapahit.org> | 2025-09-09 14:23:24 +0800 | 
| commit | 693137a6487e6ffda9ff15ade62d0e8bfec1bf49 (patch) | |
| tree | 12c078a35bebfd139d108f5fb7cd6c7fc4455c70 /indra/llcommon | |
| parent | b9ab04cd6e253848bad865fc1b5ea993a2a060f3 (diff) | |
| parent | 8a9a3dc9d760db37bb963d3e5bfadafdd94ee08d (diff) | |
Merge branch '2025.06'
Diffstat (limited to 'indra/llcommon')
| -rw-r--r-- | indra/llcommon/llassettype.cpp | 17 | ||||
| -rw-r--r-- | indra/llcommon/llassettype.h | 2 | ||||
| -rw-r--r-- | indra/llcommon/llprocessor.cpp | 3 | ||||
| -rw-r--r-- | indra/llcommon/llsdutil.h | 39 | ||||
| -rw-r--r-- | indra/llcommon/threadpool.h | 4 | ||||
| -rw-r--r-- | indra/llcommon/workqueue.cpp | 44 | ||||
| -rw-r--r-- | indra/llcommon/workqueue.h | 11 | 
7 files changed, 106 insertions, 14 deletions
| diff --git a/indra/llcommon/llassettype.cpp b/indra/llcommon/llassettype.cpp index c09cf7abd2..9672a3262b 100644 --- a/indra/llcommon/llassettype.cpp +++ b/indra/llcommon/llassettype.cpp @@ -29,6 +29,7 @@  #include "llassettype.h"  #include "lldictionary.h"  #include "llmemory.h" +#include "llsd.h"  #include "llsingleton.h"  ///---------------------------------------------------------------------------- @@ -246,3 +247,19 @@ bool LLAssetType::lookupIsAssetIDKnowable(EType asset_type)      }      return false;  } + +LLSD LLAssetType::getTypeNames() +{ +    LLSD type_names; +    const LLAssetDictionary *dict = LLAssetDictionary::getInstance(); +    for (S32 type = AT_TEXTURE; type < AT_COUNT; ++type) +    { +        const AssetEntry *entry = dict->lookup((LLAssetType::EType) type); +        // skip llassettype_bad_lookup +        if (entry) +        { +            type_names.append(entry->mTypeName); +        } +    } +    return type_names; +} diff --git a/indra/llcommon/llassettype.h b/indra/llcommon/llassettype.h index 547c3f4329..17177d81c3 100644 --- a/indra/llcommon/llassettype.h +++ b/indra/llcommon/llassettype.h @@ -165,6 +165,8 @@ public:      static bool                 lookupIsAssetFetchByIDAllowed(EType asset_type); // the asset allows direct download      static bool                 lookupIsAssetIDKnowable(EType asset_type); // asset data can be known by the viewer +    static LLSD getTypeNames(); +      static const std::string    BADLOOKUP;  protected: diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index c0b1a5c9e3..7f2276ca2a 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -669,7 +669,8 @@ public:      {          getCPUIDInfo();          uint64_t frequency = getSysctlInt64("hw.cpufrequency"); -        if (!frequency) { +        if (!frequency) +        {              auto tbfrequency = getSysctlInt64("hw.tbfrequency");              struct clockinfo clockrate;              auto clockrate_len = sizeof(clockrate); diff --git a/indra/llcommon/llsdutil.h b/indra/llcommon/llsdutil.h index c31030c5ea..497c0ad3eb 100644 --- a/indra/llcommon/llsdutil.h +++ b/indra/llcommon/llsdutil.h @@ -554,6 +554,45 @@ LLSD shallow(LLSD value, LLSD filter=LLSD()) { return llsd_shallow(value, filter  } // namespace llsd  /***************************************************************************** +*   LLSDParam<std::vector<T>> +*****************************************************************************/ +// Given an LLSD array, return a const std::vector<T>&, where T is a type +// supported by LLSDParam. Bonus: if the LLSD value is actually a scalar, +// return a single-element vector containing the converted value. +template <typename T> +class LLSDParam<std::vector<T>>: public LLSDParamBase +{ +public: +    LLSDParam(const LLSD& array) +    { +        // treat undefined "array" as empty vector +        if (array.isDefined()) +        { +            // what if it's a scalar? +            if (! array.isArray()) +            { +                v.push_back(LLSDParam<T>(array)); +            } +            else                        // really is an array +            { +                // reserve space for the array entries +                v.reserve(array.size()); +                for (const auto& item : llsd::inArray(array)) +                { +                    v.push_back(LLSDParam<T>(item)); +                } +            } +        } +    } + +    operator const std::vector<T>&() const { return v; } + +private: +    std::vector<T> v; +}; + + +/*****************************************************************************   *   toArray(), toMap()   *****************************************************************************/  namespace llsd diff --git a/indra/llcommon/threadpool.h b/indra/llcommon/threadpool.h index 0eb1891754..ac4f415f3e 100644 --- a/indra/llcommon/threadpool.h +++ b/indra/llcommon/threadpool.h @@ -55,7 +55,7 @@ namespace LL           * ThreadPool listens for application shutdown messages on the "LLApp"           * LLEventPump. Call close() to shut down this ThreadPool early.           */ -        virtual void close(); +        void close();          std::string getName() const { return mName; }          size_t getWidth() const { return mThreads.size(); } @@ -122,7 +122,7 @@ namespace LL                          size_t threads=1,                          size_t capacity=1024*1024,                          bool auto_shutdown = true): -            ThreadPoolBase(name, threads, new queue_t(name, capacity), auto_shutdown) +            ThreadPoolBase(name, threads, new queue_t(name, capacity, false), auto_shutdown)          {}          ~ThreadPoolUsing() override {} diff --git a/indra/llcommon/workqueue.cpp b/indra/llcommon/workqueue.cpp index ea4feec58c..7efaebd569 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" @@ -30,11 +31,38 @@ using Lock  = LLCoros::LockType;  /*****************************************************************************  *   WorkQueueBase  *****************************************************************************/ -LL::WorkQueueBase::WorkQueueBase(const std::string& name): -    super(makeName(name)) +LL::WorkQueueBase::WorkQueueBase(const std::string& name, bool auto_shutdown) +  : super(makeName(name))  { -    // TODO: register for "LLApp" events so we can implicitly close() on -    // viewer shutdown. +    if (auto_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() @@ -220,8 +248,8 @@ void LL::WorkQueueBase::checkCoroutine(const std::string& method)  /*****************************************************************************  *   WorkQueue  *****************************************************************************/ -LL::WorkQueue::WorkQueue(const std::string& name, size_t capacity): -    super(name), +LL::WorkQueue::WorkQueue(const std::string& name, size_t capacity, bool auto_shutdown): +    super(name, auto_shutdown),      mQueue(capacity)  {  } @@ -269,8 +297,8 @@ bool LL::WorkQueue::tryPop_(Work& work)  /*****************************************************************************  *   WorkSchedule  *****************************************************************************/ -LL::WorkSchedule::WorkSchedule(const std::string& name, size_t capacity): -    super(name), +LL::WorkSchedule::WorkSchedule(const std::string& name, size_t capacity, bool auto_shutdown): +    super(name, auto_shutdown),      mQueue(capacity)  {  } diff --git a/indra/llcommon/workqueue.h b/indra/llcommon/workqueue.h index 9d7bbfbf7a..735ad38a26 100644 --- a/indra/llcommon/workqueue.h +++ b/indra/llcommon/workqueue.h @@ -51,7 +51,9 @@ namespace LL           * You may omit the WorkQueueBase name, in which case a unique name is           * synthesized; for practical purposes that makes it anonymous.           */ -        WorkQueueBase(const std::string& name); +        WorkQueueBase(const std::string& name, bool auto_shutdown); + +        virtual ~WorkQueueBase();          /**           * Since the point of WorkQueue is to pass work to some other worker @@ -197,6 +199,9 @@ namespace LL      private:          virtual Work pop_() = 0;          virtual bool tryPop_(Work&) = 0; + +        // Name used for the LLApp event listener (empty if not registered) +        std::string mListenerName;      };  /***************************************************************************** @@ -212,7 +217,7 @@ namespace LL           * You may omit the WorkQueue name, in which case a unique name is           * synthesized; for practical purposes that makes it anonymous.           */ -        WorkQueue(const std::string& name = std::string(), size_t capacity=1024); +        WorkQueue(const std::string& name = std::string(), size_t capacity=1024, bool auto_shutdown = true);          /**           * Since the point of WorkQueue is to pass work to some other worker @@ -282,7 +287,7 @@ namespace LL           * You may omit the WorkSchedule name, in which case a unique name is           * synthesized; for practical purposes that makes it anonymous.           */ -        WorkSchedule(const std::string& name = std::string(), size_t capacity=1024); +        WorkSchedule(const std::string& name = std::string(), size_t capacity=1024, bool auto_shutdown = true);          /**           * Since the point of WorkSchedule is to pass work to some other worker | 
