summaryrefslogtreecommitdiff
path: root/indra/llmessage/llcoproceduremanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmessage/llcoproceduremanager.cpp')
-rw-r--r--indra/llmessage/llcoproceduremanager.cpp55
1 files changed, 23 insertions, 32 deletions
diff --git a/indra/llmessage/llcoproceduremanager.cpp b/indra/llmessage/llcoproceduremanager.cpp
index 062f2e6e42..f0fe1ab01b 100644
--- a/indra/llmessage/llcoproceduremanager.cpp
+++ b/indra/llmessage/llcoproceduremanager.cpp
@@ -27,13 +27,16 @@
#include "linden_common.h"
#include "llcoproceduremanager.h"
+#include <boost/assign.hpp>
//=========================================================================
// Map of pool sizes for known pools
-static std::map<std::string, U32> DefaultPoolSizes;
-
// *TODO$: When C++11 this can be initialized here as follows:
// = {{"AIS", 25}, {"Upload", 1}}
+static std::map<std::string, U32> DefaultPoolSizes =
+ boost::assign::map_list_of
+ (std::string("Upload"), 1)
+ (std::string("AIS"), 25);
#define DEFAULT_POOL_SIZE 5
@@ -55,7 +58,7 @@ public:
LLUUID enqueueCoprocedure(const std::string &name, CoProcedure_t proc);
/// Cancel a coprocedure. If the coprocedure is already being actively executed
- /// this method calls cancelYieldingOperation() on the associated HttpAdapter
+ /// this method calls cancelSuspendedOperation() on the associated HttpAdapter
/// If it has not yet been dequeued it is simply removed from the queue.
bool cancelCoprocedure(const LLUUID &id);
@@ -124,8 +127,6 @@ private:
//=========================================================================
LLCoprocedureManager::LLCoprocedureManager()
{
- DefaultPoolSizes.insert(std::map<std::string, U32>::value_type("Upload", 1));
- DefaultPoolSizes.insert(std::map<std::string, U32>::value_type("AIS", 25));
}
LLCoprocedureManager::~LLCoprocedureManager()
@@ -139,6 +140,9 @@ LLCoprocedureManager::poolPtr_t LLCoprocedureManager::initializePool(const std::
std::string keyName = "PoolSize" + poolName;
int size = 0;
+ if (poolName.empty())
+ LL_ERRS("CoprocedureManager") << "Poolname must not be empty" << LL_ENDL;
+
if (mPropertyQueryFn && !mPropertyQueryFn.empty())
{
size = mPropertyQueryFn(keyName);
@@ -158,9 +162,11 @@ LLCoprocedureManager::poolPtr_t LLCoprocedureManager::initializePool(const std::
LL_WARNS() << "LLCoprocedureManager: No setting for \"" << keyName << "\" setting pool size to default of " << size << LL_ENDL;
}
- poolPtr_t pool = poolPtr_t(new LLCoprocedurePool(poolName, size));
+ poolPtr_t pool(new LLCoprocedurePool(poolName, size));
mPoolMap.insert(poolMap_t::value_type(poolName, pool));
+ if (!pool)
+ LL_ERRS("CoprocedureManager") << "Unable to create pool named \"" << poolName << "\" FATAL!" << LL_ENDL;
return pool;
}
@@ -181,12 +187,6 @@ LLUUID LLCoprocedureManager::enqueueCoprocedure(const std::string &pool, const s
targetPool = (*it).second;
}
- if (!targetPool)
- {
- LL_WARNS() << "LLCoprocedureManager unable to create coprocedure pool named \"" << pool << "\"" << LL_ENDL;
- return LLUUID::null;
- }
-
return targetPool->enqueueCoprocedure(name, proc);
}
@@ -285,14 +285,12 @@ LLCoprocedurePool::LLCoprocedurePool(const std::string &poolName, size_t size):
{
for (size_t count = 0; count < mPoolSize; ++count)
{
- LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter =
- LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t(
- new LLCoreHttpUtil::HttpCoroutineAdapter( mPoolName + "Adapter", mHTTPPolicy));
+ LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter( mPoolName + "Adapter", mHTTPPolicy));
- std::string uploadCoro = LLCoros::instance().launch("LLCoprocedurePool("+mPoolName+")::coprocedureInvokerCoro",
+ std::string pooledCoro = LLCoros::instance().launch("LLCoprocedurePool("+mPoolName+")::coprocedureInvokerCoro",
boost::bind(&LLCoprocedurePool::coprocedureInvokerCoro, this, httpAdapter));
- mCoroMapping.insert(CoroAdapterMap_t::value_type(uploadCoro, httpAdapter));
+ mCoroMapping.insert(CoroAdapterMap_t::value_type(pooledCoro, httpAdapter));
}
LL_INFOS() << "Created coprocedure pool named \"" << mPoolName << "\" with " << size << " items." << LL_ENDL;
@@ -312,16 +310,13 @@ void LLCoprocedurePool::shutdown(bool hardShutdown)
for (it = mCoroMapping.begin(); it != mCoroMapping.end(); ++it)
{
- if (!(*it).first.empty())
+ if (hardShutdown)
{
- if (hardShutdown)
- {
- LLCoros::instance().kill((*it).first);
- }
+ LLCoros::instance().kill((*it).first);
}
if ((*it).second)
{
- (*it).second->cancelYieldingOperation();
+ (*it).second->cancelSuspendedOperation();
}
}
@@ -350,7 +345,7 @@ bool LLCoprocedurePool::cancelCoprocedure(const LLUUID &id)
if (itActive != mActiveCoprocs.end())
{
LL_INFOS() << "Found and canceling active coprocedure with id=" << id.asString() << " in pool \"" << mPoolName << "\"" << LL_ENDL;
- (*itActive).second->cancelYieldingOperation();
+ (*itActive).second->cancelSuspendedOperation();
mActiveCoprocs.erase(itActive);
return true;
}
@@ -365,7 +360,7 @@ bool LLCoprocedurePool::cancelCoprocedure(const LLUUID &id)
}
}
- LL_INFOS() << "Coprocedure with Id=" << id.asString() << " was not found." << " in pool \"" << mPoolName << "\"" << LL_ENDL;
+ LL_INFOS() << "Coprocedure with Id=" << id.asString() << " was not found in pool \"" << mPoolName << "\"" << LL_ENDL;
return false;
}
@@ -376,7 +371,7 @@ void LLCoprocedurePool::coprocedureInvokerCoro(LLCoreHttpUtil::HttpCoroutineAdap
while (!mShutdown)
{
- llcoro::waitForEventOn(mWakeupTrigger);
+ llcoro::suspendUntilEventOn(mWakeupTrigger);
if (mShutdown)
break;
@@ -384,7 +379,7 @@ void LLCoprocedurePool::coprocedureInvokerCoro(LLCoreHttpUtil::HttpCoroutineAdap
{
QueuedCoproc::ptr_t coproc = mPendingCoprocs.front();
mPendingCoprocs.pop_front();
- mActiveCoprocs.insert(ActiveCoproc_t::value_type(coproc->mId, httpAdapter));
+ ActiveCoproc_t::iterator itActive = mActiveCoprocs.insert(ActiveCoproc_t::value_type(coproc->mId, httpAdapter)).first;
LL_INFOS() << "Dequeued and invoking coprocedure(" << coproc->mName << ") with id=" << coproc->mId.asString() << " in pool \"" << mPoolName << "\"" << LL_ENDL;
@@ -404,11 +399,7 @@ void LLCoprocedurePool::coprocedureInvokerCoro(LLCoreHttpUtil::HttpCoroutineAdap
LL_INFOS() << "Finished coprocedure(" << coproc->mName << ")" << " in pool \"" << mPoolName << "\"" << LL_ENDL;
- ActiveCoproc_t::iterator itActive = mActiveCoprocs.find(coproc->mId);
- if (itActive != mActiveCoprocs.end())
- {
- mActiveCoprocs.erase(itActive);
- }
+ mActiveCoprocs.erase(itActive);
}
}
}