diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2022-06-09 11:22:01 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2022-06-09 11:22:01 -0400 |
commit | 0bf91fc141c988d61bc5c593766981e71454d6fd (patch) | |
tree | c48e513cbcaf395ab753e290acfe740a50493fa4 /indra/llcommon/threadpool.h | |
parent | f4473528eb3f37b4bec3c4cda2a83d9ca94ab133 (diff) | |
parent | 1ff79a430d9d55cbb4b4ba55018c791a8a933916 (diff) |
SL-17483: Merge branch 'track-threadpools' into sl-17483.
This picks up ThreadPoolSizes override logic embedded in ThreadPool's
constructor, plus the new static ThreadPool::getConfiguredWidth() and
getWidth() methods.
Diffstat (limited to 'indra/llcommon/threadpool.h')
-rw-r--r-- | indra/llcommon/threadpool.h | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/indra/llcommon/threadpool.h b/indra/llcommon/threadpool.h index b79c9b9090..b49d511257 100644 --- a/indra/llcommon/threadpool.h +++ b/indra/llcommon/threadpool.h @@ -22,14 +22,25 @@ namespace LL { - class ThreadPool + class ThreadPool: public LLInstanceTracker<ThreadPool, std::string> { + private: + using super = LLInstanceTracker<ThreadPool, std::string>; public: /** * Pass ThreadPool a string name. This can be used to look up the * relevant WorkQueue. + * + * The number of threads you pass sets the compile-time default. But + * if the user has overridden the LLSD map in the "ThreadPoolSizes" + * setting with a key matching this ThreadPool name, that setting + * overrides this parameter. + * + * Pass an explicit capacity to limit the size of the queue. + * Constraining the queue can cause a submitter to block. Do not + * constrain any ThreadPool accepting work from the main thread. */ - 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*1024); virtual ~ThreadPool(); /** @@ -57,6 +68,25 @@ namespace LL */ virtual void run(); + /** + * getConfiguredWidth() returns the setting, if any, for the specified + * ThreadPool name. Returns dft if the "ThreadPoolSizes" map does not + * contain the specified name. + */ + static + size_t getConfiguredWidth(const std::string& name, size_t dft=0); + + /** + * This getWidth() returns the width of the instantiated ThreadPool + * with the specified name, if any. If no instance exists, returns its + * getConfiguredWidth() if any. If there's no instance and no relevant + * override, return dft. Presumably dft should match the threads + * parameter passed to the ThreadPool constructor call that will + * eventually instantiate the ThreadPool with that name. + */ + static + size_t getWidth(const std::string& name, size_t dft); + private: void run(const std::string& name); |