summaryrefslogtreecommitdiff
path: root/indra/newview/llmainlooprepeater.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2021-10-22 11:36:31 -0400
committerNat Goodspeed <nat@lindenlab.com>2021-10-22 11:36:31 -0400
commit11afa09ea3f56c0e20eb195ae1520a88602ceaca (patch)
treeb5f567f6c34133e288f648b60202eae6ae1c4a89 /indra/newview/llmainlooprepeater.cpp
parenteda264c2821a86505b4ec2a898ff3169ab82f895 (diff)
SL-16220: Add LL::ThreadPool class and a "General" instance.
ThreadPool bundles a WorkQueue with the specified number of worker threads to service it. Each ThreadPool has a name that can be used to locate its WorkQueue. Each worker thread calls WorkQueue::runUntilClose(). ThreadPool listens on the "LLApp" LLEventPump for shutdown notification. On receiving that, it closes its WorkQueue and then join()s each of its worker threads for orderly shutdown. Add a settings.xml entry "ThreadPoolSizes", the first LLSD-valued settings entry to expect a map: pool name->size. The expectation is that usually code instantiating a particular ThreadPool will have a default size in mind, but it should check "ThreadPoolSizes" for a user override. Make idle_startup()'s STATE_SEED_CAP_GRANTED state instantiate a "General" ThreadPool. This is function-static for lazy initialization. Eliminate LLMainLoopRepeater, which is completely unreferenced. Any potential future use cases are better addressed by posting to the main loop's WorkQueue. Eliminate llappviewer.cpp's private LLDeferredTaskList class, which implemented LLAppViewer::addOnIdleCallback(). Make addOnIdleCallback() post work to the main loop's WorkQueue instead.
Diffstat (limited to 'indra/newview/llmainlooprepeater.cpp')
-rw-r--r--indra/newview/llmainlooprepeater.cpp88
1 files changed, 0 insertions, 88 deletions
diff --git a/indra/newview/llmainlooprepeater.cpp b/indra/newview/llmainlooprepeater.cpp
deleted file mode 100644
index 6736e9a950..0000000000
--- a/indra/newview/llmainlooprepeater.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * @file llmachineid.cpp
- * @brief retrieves unique machine ids
- *
- * $LicenseInfo:firstyear=2009&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-#include "llapr.h"
-#include "llevents.h"
-#include "llmainlooprepeater.h"
-
-
-
-// LLMainLoopRepeater
-//-----------------------------------------------------------------------------
-
-
-LLMainLoopRepeater::LLMainLoopRepeater(void):
- mQueue(0)
-{
- ; // No op.
-}
-
-
-void LLMainLoopRepeater::start(void)
-{
- if(mQueue != 0) return;
-
- mQueue = new LLThreadSafeQueue<LLSD>(1024);
- mMainLoopConnection = LLEventPumps::instance().
- obtain("mainloop").listen(LLEventPump::inventName(), boost::bind(&LLMainLoopRepeater::onMainLoop, this, _1));
- mRepeaterConnection = LLEventPumps::instance().
- obtain("mainlooprepeater").listen(LLEventPump::inventName(), boost::bind(&LLMainLoopRepeater::onMessage, this, _1));
-}
-
-
-void LLMainLoopRepeater::stop(void)
-{
- mMainLoopConnection.release();
- mRepeaterConnection.release();
-
- delete mQueue;
- mQueue = 0;
-}
-
-
-bool LLMainLoopRepeater::onMainLoop(LLSD const &)
-{
- LLSD message;
- while(mQueue->tryPopBack(message)) {
- std::string pump = message["pump"].asString();
- if(pump.length() == 0 ) continue; // No pump.
- LLEventPumps::instance().obtain(pump).post(message["payload"]);
- }
- return false;
-}
-
-
-bool LLMainLoopRepeater::onMessage(LLSD const & event)
-{
- try {
- mQueue->pushFront(event);
- } catch(LLThreadSafeQueueError & e) {
- LL_WARNS() << "could not repeat message (" << e.what() << ")" <<
- event.asString() << LL_ENDL;
- }
- return false;
-}