summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xindra/newview/llaccountingcostmanager.cpp87
-rwxr-xr-xindra/newview/llaccountingcostmanager.h7
-rwxr-xr-xindra/newview/llviewerobjectlist.cpp69
-rwxr-xr-xindra/newview/llviewerobjectlist.h10
4 files changed, 81 insertions, 92 deletions
diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp
index d5027d13fa..92a5413adb 100755
--- a/indra/newview/llaccountingcostmanager.cpp
+++ b/indra/newview/llaccountingcostmanager.cpp
@@ -31,14 +31,12 @@
#include "llcoros.h"
#include "lleventcoro.h"
#include "llcorehttputil.h"
+#include <algorithm>
+#include <iterator>
//===============================================================================
-LLAccountingCostManager::LLAccountingCostManager():
- mHttpRequest(),
- mHttpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID)
+LLAccountingCostManager::LLAccountingCostManager()
{
- mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest());
- //mHttpPolicy = LLCore::HttpRequest::DEFAULT_POLICY_ID;
}
@@ -51,30 +49,24 @@ void LLAccountingCostManager::accountingCostCoro(std::string url,
LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::instance().getName()
<< " with url '" << url << LL_ENDL;
+ LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
+ LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
+ httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("AccountingCost", httpPolicy));
+ LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
+
try
{
- LLSD objectList;
- U32 objectIndex = 0;
+ uuid_set_t diffSet;
- IDIt IDIter = mObjectList.begin();
- IDIt IDIterEnd = mObjectList.end();
+ std::set_difference(mObjectList.begin(), mObjectList.end(),
+ mPendingObjectQuota.begin(), mPendingObjectQuota.end(),
+ std::inserter(diffSet, diffSet.begin()));
- for (; IDIter != IDIterEnd; ++IDIter)
- {
- // Check to see if a request for this object has already been made.
- if (mPendingObjectQuota.find(*IDIter) == mPendingObjectQuota.end())
- {
- mPendingObjectQuota.insert(*IDIter);
- objectList[objectIndex++] = *IDIter;
- }
- }
+ if (diffSet.empty())
+ return;
mObjectList.clear();
- //Post results
- if (objectList.size() == 0)
- return;
-
std::string keystr;
if (selectionType == Roots)
{
@@ -87,11 +79,18 @@ void LLAccountingCostManager::accountingCostCoro(std::string url,
else
{
LL_INFOS() << "Invalid selection type " << LL_ENDL;
- mObjectList.clear();
- mPendingObjectQuota.clear();
return;
}
+ LLSD objectList(LLSD::emptyMap());
+
+ for (uuid_set_t::iterator it = diffSet.begin(); it != diffSet.end(); ++it)
+ {
+ objectList.append(*it);
+ }
+
+ mPendingObjectQuota.insert(diffSet.begin(), diffSet.end());
+
LLSD dataToPost = LLSD::emptyMap();
dataToPost[keystr.c_str()] = objectList;
@@ -99,27 +98,27 @@ void LLAccountingCostManager::accountingCostCoro(std::string url,
LLUUID transactionId = observer->getTransactionID();
observer = NULL;
- LLCoreHttpUtil::HttpCoroutineAdapter httpAdapter("AccountingCost", mHttpPolicy);
- LLSD results = httpAdapter.postAndSuspend(mHttpRequest, url, dataToPost);
- LLSD httpResults;
- httpResults = results["http_result"];
+ LLSD results = httpAdapter->postAndSuspend(httpRequest, url, dataToPost);
+
+ LLSD httpResults = results["http_result"];
+ LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
// do/while(false) allows error conditions to break out of following
// block while normal flow goes forward once.
do
{
observer = observerHandle.get();
- if ((!observer) || (observer->getTransactionID() != transactionId))
- { // *TODO: Rider: I've noticed that getTransactionID() does not
- // always match transactionId (the new transaction Id does not show a
- // corresponding request.) (ask Vir)
- if (!observer)
- break;
- LL_WARNS() << "Request transaction Id(" << transactionId
- << ") does not match observer's transaction Id("
- << observer->getTransactionID() << ")." << LL_ENDL;
+
+ if (!status || results.has("error"))
+ {
+ LL_WARNS() << "Error on fetched data" << LL_ENDL;
+ if (!status)
+ observer->setErrorStatus(status.getType(), status.toString());
+ else
+ observer->setErrorStatus(499, "Error on fetched data");
+
break;
}
@@ -134,22 +133,18 @@ void LLAccountingCostManager::accountingCostCoro(std::string url,
break;
}
- if (!results.isMap() || results.has("error"))
- {
- LL_WARNS() << "Error on fetched data" << LL_ENDL;
- observer->setErrorStatus(499, "Error on fetched data");
- break;
- }
if (results.has("selected"))
{
+ LLSD selected = results["selected"];
+
F32 physicsCost = 0.0f;
F32 networkCost = 0.0f;
F32 simulationCost = 0.0f;
- physicsCost = results["selected"]["physics"].asReal();
- networkCost = results["selected"]["streaming"].asReal();
- simulationCost = results["selected"]["simulation"].asReal();
+ physicsCost = selected["physics"].asReal();
+ networkCost = selected["streaming"].asReal();
+ simulationCost = selected["simulation"].asReal();
SelectionCost selectionCost( physicsCost, networkCost, simulationCost);
diff --git a/indra/newview/llaccountingcostmanager.h b/indra/newview/llaccountingcostmanager.h
index d5a94f6fda..f251ceffd4 100755
--- a/indra/newview/llaccountingcostmanager.h
+++ b/indra/newview/llaccountingcostmanager.h
@@ -71,16 +71,13 @@ public:
private:
//Set of objects that will be used to generate a cost
- std::set<LLUUID> mObjectList;
+ uuid_set_t mObjectList;
//During fetchCosts we move object into a the pending set to signify that
//a fetch has been instigated.
- std::set<LLUUID> mPendingObjectQuota;
- typedef std::set<LLUUID>::iterator IDIt;
+ uuid_set_t mPendingObjectQuota;
void accountingCostCoro(std::string url, eSelectionType selectionType, const LLHandle<LLAccountingCostObserver> observerHandle);
- LLCore::HttpRequest::ptr_t mHttpRequest;
- LLCore::HttpRequest::policy_t mHttpPolicy;
};
//===============================================================================
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index e193e8431e..5f01cdbb6f 100755
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -80,6 +80,9 @@
#include "llvocache.h"
#include "llcorehttputil.h"
+#include <algorithm>
+#include <iterator>
+
extern F32 gMinObjectDistance;
extern BOOL gAnimateTextures;
@@ -1021,33 +1024,30 @@ void LLViewerObjectList::fetchObjectCostsCoro(std::string url)
httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy));
LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
- LLSD idList;
- U32 objectIndex = 0;
- for (std::set<LLUUID>::iterator it = mStaleObjectCost.begin(); it != mStaleObjectCost.end(); )
- {
- // Check to see if a request for this object
- // has already been made.
- if (mPendingObjectCost.find(*it) == mPendingObjectCost.end())
- {
- mPendingObjectCost.insert(*it);
- idList[objectIndex++] = *it;
- }
- mStaleObjectCost.erase(it++);
+ uuid_set_t diff;
- if (objectIndex >= MAX_CONCURRENT_PHYSICS_REQUESTS)
- {
- break;
- }
- }
+ std::set_difference(mStaleObjectCost.begin(), mStaleObjectCost.end(),
+ mPendingObjectCost.begin(), mPendingObjectCost.end(),
+ std::inserter(diff, diff.begin()));
- if (idList.size() < 1)
+ if (diff.empty())
{
LL_INFOS() << "No outstanding object IDs to request." << LL_ENDL;
return;
}
-
+
+ LLSD idList(LLSD::emptyArray());
+
+ for (uuid_set_t::iterator it = diff.begin(); it != diff.end(); ++it)
+ {
+ idList.append(*it);
+ mStaleObjectCost.erase(*it);
+ }
+
+ mPendingObjectCost.insert(diff.begin(), diff.end());
+
LLSD postData = LLSD::emptyMap();
postData["object_ids"] = idList;
@@ -1080,29 +1080,28 @@ void LLViewerObjectList::fetchObjectCostsCoro(std::string url)
{
LLUUID objectId = it->asUUID();
+ // If the object was added to the StaleObjectCost set after it had been
+ // added to mPendingObjectCost it would still be in the StaleObjectCost
+ // set when we got the response back.
+ mStaleObjectCost.erase(objectId);
+ mPendingObjectCost.erase(objectId);
+
// Check to see if the request contains data for the object
if (result.has(it->asString()))
{
- const LLSD& data = result[it->asString()];
+ LLSD objectData = result[it->asString()];
- S32 shapeType = data["PhysicsShapeType"].asInteger();
-
- gObjectList.updatePhysicsShapeType(objectId, shapeType);
-
- if (data.has("Density"))
- {
- F32 density = data["Density"].asReal();
- F32 friction = data["Friction"].asReal();
- F32 restitution = data["Restitution"].asReal();
- F32 gravityMult = data["GravityMultiplier"].asReal();
+ F32 linkCost = objectData["linked_set_resource_cost"].asReal();
+ F32 objectCost = objectData["resource_cost"].asReal();
+ F32 physicsCost = objectData["physics_cost"].asReal();
+ F32 linkPhysicsCost = objectData["linked_set_physics_cost"].asReal();
- gObjectList.updatePhysicsProperties(objectId, density, friction, restitution, gravityMult);
- }
+ gObjectList.updateObjectCost(objectId, objectCost, linkCost, physicsCost, linkPhysicsCost);
}
else
{
// TODO*: Give user feedback about the missing data?
- gObjectList.onPhysicsFlagsFetchFailure(objectId);
+ gObjectList.onObjectCostFetchFailure(objectId);
}
}
@@ -1153,7 +1152,7 @@ void LLViewerObjectList::fetchPhisicsFlagsCoro(std::string url)
LLSD idList;
U32 objectIndex = 0;
- for (std::set<LLUUID>::iterator it = mStalePhysicsFlags.begin(); it != mStalePhysicsFlags.end(); )
+ for (uuid_set_t::iterator it = mStalePhysicsFlags.begin(); it != mStalePhysicsFlags.end();)
{
// Check to see if a request for this object
// has already been made.
@@ -1522,8 +1521,6 @@ void LLViewerObjectList::updateObjectCost(LLViewerObject* object)
void LLViewerObjectList::updateObjectCost(const LLUUID& object_id, F32 object_cost, F32 link_cost, F32 physics_cost, F32 link_physics_cost)
{
- mPendingObjectCost.erase(object_id);
-
LLViewerObject* object = findObject(object_id);
if (object)
{
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index 9ec7c4bc22..94c751acc6 100755
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -205,17 +205,17 @@ protected:
vobj_list_t mMapObjects;
- std::set<LLUUID> mDeadObjects;
+ uuid_set_t mDeadObjects;
std::map<LLUUID, LLPointer<LLViewerObject> > mUUIDObjectMap;
//set of objects that need to update their cost
- std::set<LLUUID> mStaleObjectCost;
- std::set<LLUUID> mPendingObjectCost;
+ uuid_set_t mStaleObjectCost;
+ uuid_set_t mPendingObjectCost;
//set of objects that need to update their physics flags
- std::set<LLUUID> mStalePhysicsFlags;
- std::set<LLUUID> mPendingPhysicsFlags;
+ uuid_set_t mStalePhysicsFlags;
+ uuid_set_t mPendingPhysicsFlags;
std::vector<LLDebugBeacon> mDebugBeacons;