summaryrefslogtreecommitdiff
path: root/indra/llcommon/threadpool.h
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2024-04-12 17:05:23 +0300
committerGitHub <noreply@github.com>2024-04-12 17:05:23 +0300
commit9bc190c8d3ddd7a692636bb349952144fd511622 (patch)
tree07b0a9297a67667b5c85c4eb4950628e344c5106 /indra/llcommon/threadpool.h
parentf5a7fba76a24a96f906abcbd928f37e4eabfa76c (diff)
parenteab5beb54cacc2b0dc2cddad4a78634e7468a298 (diff)
Merge pull request #1211 from secondlife/marchcat/x-merge
Release (Maint W) -> Maint X merge
Diffstat (limited to 'indra/llcommon/threadpool.h')
-rw-r--r--indra/llcommon/threadpool.h14
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 {}