diff options
author | Nat Linden <nat@lindenlab.com> | 2022-06-13 19:50:49 +0000 |
---|---|---|
committer | Nat Linden <nat@lindenlab.com> | 2022-06-13 19:50:49 +0000 |
commit | c9a48a1cdd23a592eb25454d5e2d6c316ec93445 (patch) | |
tree | 614d3ae0efdcbec1211d638e602cdb2d78aa8057 /indra/llcommon/threadpool.h | |
parent | da069765b1974e60df5ebf9e973c7fd00c52e329 (diff) | |
parent | 3b043d90b60eca17dfcc014b21c4c8fc5b432384 (diff) |
Merged in sl-17483 (pull request #1014)
SL-17483: Make LLImageDecodeThread a facade for LL::ThreadPool.
Approved-by: Dave Parks
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); |