diff options
author | Dave Houlton <euclid@lindenlab.com> | 2021-11-15 09:25:35 -0700 |
---|---|---|
committer | Dave Houlton <euclid@lindenlab.com> | 2021-11-15 09:25:35 -0700 |
commit | 029b41c0419e975bbb28454538b46dc69ce5d2ba (patch) | |
tree | 4f9a28bb36ee07fe9a7b45a434384afd1f24bb85 /indra/llcommon/threadpool.cpp | |
parent | aeed774ff9cc55c0c1dd2784e23b2366ff367fbe (diff) |
Revert "SL-16220: Merge branch 'origin/DRTVWR-546' into glthread"
This reverts commit 5188a26a8521251dda07ac0140bb129f28417e49, reversing
changes made to 819088563e13f1d75e048311fbaf0df4a79b7e19.
Diffstat (limited to 'indra/llcommon/threadpool.cpp')
-rw-r--r-- | indra/llcommon/threadpool.cpp | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/indra/llcommon/threadpool.cpp b/indra/llcommon/threadpool.cpp deleted file mode 100644 index cf25cc838e..0000000000 --- a/indra/llcommon/threadpool.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @file threadpool.cpp - * @author Nat Goodspeed - * @date 2021-10-21 - * @brief Implementation for threadpool. - * - * $LicenseInfo:firstyear=2021&license=viewerlgpl$ - * Copyright (c) 2021, Linden Research, Inc. - * $/LicenseInfo$ - */ - -// Precompiled header -#include "linden_common.h" -// associated header -#include "threadpool.h" -// STL headers -// std headers -// external library headers -// other Linden headers -#include "llerror.h" -#include "llevents.h" -#include "stringize.h" - -LL::ThreadPool::ThreadPool(const std::string& name, size_t threads, size_t capacity): - mQueue(name, capacity), - mName("ThreadPool:" + name) -{ - for (size_t i = 0; i < threads; ++i) - { - std::string tname{ STRINGIZE(mName << ':' << (i+1) << '/' << threads) }; - mThreads.emplace_back(tname, [this, tname](){ run(tname); }); - } - // Listen on "LLApp", and when the app is shutting down, close the queue - // and join the workers. - LLEventPumps::instance().obtain("LLApp").listen( - mName, - [this](const LLSD& stat) - { - std::string status(stat["status"]); - if (status != "running") - { - // viewer is starting shutdown -- proclaim the end is nigh! - LL_DEBUGS("ThreadPool") << mName << " saw " << status << LL_ENDL; - close(); - } - return false; - }); -} - -LL::ThreadPool::~ThreadPool() -{ - close(); -} - -void LL::ThreadPool::close() -{ - if (! mQueue.isClosed()) - { - LL_DEBUGS("ThreadPool") << mName << " closing queue and joining threads" << LL_ENDL; - mQueue.close(); - for (auto& pair: mThreads) - { - LL_DEBUGS("ThreadPool") << mName << " waiting on thread " << pair.first << LL_ENDL; - pair.second.join(); - } - LL_DEBUGS("ThreadPool") << mName << " shutdown complete" << LL_ENDL; - } -} - -void LL::ThreadPool::run(const std::string& name) -{ - LL_DEBUGS("ThreadPool") << name << " starting" << LL_ENDL; - run(); - LL_DEBUGS("ThreadPool") << name << " stopping" << LL_ENDL; -} - -void LL::ThreadPool::run() -{ - mQueue.runUntilClose(); -} |