diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-04-16 15:25:25 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-04-16 15:25:25 -0400 |
commit | 78d985c154b0d71064b89891f5b2005e48c300ce (patch) | |
tree | c43bc6be58ec9b30f0f4dfaa6c027736fb331582 /indra/llcommon/threadpool.h | |
parent | 6c2a278c3dbd9d0660be5e9f6ec1c756af7cb992 (diff) | |
parent | a3cbd41543258818589dd0e368c68d2dc62b3398 (diff) |
Merge branch 'main' into release/luau-scripting
Diffstat (limited to 'indra/llcommon/threadpool.h')
-rw-r--r-- | indra/llcommon/threadpool.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/indra/llcommon/threadpool.h b/indra/llcommon/threadpool.h index 60f4a0ce1b..74056aea17 100644 --- a/indra/llcommon/threadpool.h +++ b/indra/llcommon/threadpool.h @@ -40,7 +40,7 @@ namespace LL * overrides this parameter. */ ThreadPoolBase(const std::string& name, size_t threads, - WorkQueueBase* queue); + WorkQueueBase* queue, bool auto_shutdown = true); virtual ~ThreadPoolBase(); /** @@ -55,7 +55,7 @@ namespace LL * ThreadPool listens for application shutdown messages on the "LLApp" * LLEventPump. Call close() to shut down this ThreadPool early. */ - void close(); + virtual void close(); std::string getName() const { return mName; } size_t getWidth() const { return mThreads.size(); } @@ -87,13 +87,14 @@ namespace LL protected: std::unique_ptr<WorkQueueBase> mQueue; + std::vector<std::pair<std::string, std::thread>> mThreads; + bool mAutomaticShutdown; private: void run(const std::string& name); std::string mName; size_t mThreadCount; - std::vector<std::pair<std::string, std::thread>> mThreads; }; /** @@ -117,8 +118,11 @@ namespace LL * Constraining the queue can cause a submitter to block. Do not * constrain any ThreadPool accepting work from the main thread. */ - ThreadPoolUsing(const std::string& name, size_t threads=1, size_t capacity=1024*1024): - ThreadPoolBase(name, threads, new queue_t(name, capacity)) + ThreadPoolUsing(const std::string& name, + size_t threads=1, + size_t capacity=1024*1024, + bool auto_shutdown = true): + ThreadPoolBase(name, threads, new queue_t(name, capacity), auto_shutdown) {} ~ThreadPoolUsing() override {} |