diff options
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/threadpool.cpp | 10 | ||||
-rw-r--r-- | indra/llcommon/threadpool.h | 9 |
2 files changed, 16 insertions, 3 deletions
diff --git a/indra/llcommon/threadpool.cpp b/indra/llcommon/threadpool.cpp index 06e0dc5bfc..ba914035e2 100644 --- a/indra/llcommon/threadpool.cpp +++ b/indra/llcommon/threadpool.cpp @@ -23,11 +23,15 @@ LL::ThreadPool::ThreadPool(const std::string& name, size_t threads, size_t capacity): mQueue(name, capacity), - mName("ThreadPool:" + name) + mName("ThreadPool:" + name), + mThreadCount(threads) +{} + +void LL::ThreadPool::start() { - for (size_t i = 0; i < threads; ++i) + for (size_t i = 0; i < mThreadCount; ++i) { - std::string tname{ STRINGIZE(mName << ':' << (i+1) << '/' << threads) }; + std::string tname{ stringize(mName, ':', (i+1), '/', mThreadCount) }; mThreads.emplace_back(tname, [this, tname]() { LL_PROFILER_SET_THREAD_NAME(tname.c_str()); diff --git a/indra/llcommon/threadpool.h b/indra/llcommon/threadpool.h index 1ca24aec58..b79c9b9090 100644 --- a/indra/llcommon/threadpool.h +++ b/indra/llcommon/threadpool.h @@ -33,6 +33,14 @@ namespace LL virtual ~ThreadPool(); /** + * Launch the ThreadPool. Until this call, a constructed ThreadPool + * launches no threads. That permits coders to derive from ThreadPool, + * or store it as a member of some other class, but refrain from + * launching it until all other construction is complete. + */ + void start(); + + /** * ThreadPool listens for application shutdown messages on the "LLApp" * LLEventPump. Call close() to shut down this ThreadPool early. */ @@ -54,6 +62,7 @@ namespace LL WorkQueue mQueue; std::string mName; + size_t mThreadCount; std::vector<std::pair<std::string, std::thread>> mThreads; }; |