Changeset 3084 for code/trunk/src/network/TrafficControl.cc
- Timestamp:
- May 26, 2009, 9:20:57 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/network/TrafficControl.cc
r2896 r3084 21 21 * 22 22 * Author: 23 * Oliver Scheuss <scheusso [at] ee.ethz.ch> , (C) 200823 * Oliver Scheuss <scheusso [at] ee.ethz.ch> 24 24 * Co-authors: 25 25 * ... … … 91 91 void TrafficControl::setConfigValues() 92 92 { 93 SetConfigValue ( bActive_, true );94 SetConfigValue ( targetSize, 5000 );93 SetConfigValue ( bActive_, false ); 94 SetConfigValue ( targetSize, 10000 ); 95 95 } 96 96 … … 121 121 122 122 123 void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj> *list) 124 { 125 // copiedVector = *list; 123 void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj>& list) 124 { 126 125 currentClientID=clientID; 127 126 currentGamestateID=gamestateID; … … 143 142 assert(clientListTemp_.find(clientID) != clientListTemp_.end() ); 144 143 assert(clientListPerm_.find(clientID) != clientListPerm_.end() ); 145 assert( clientListTemp_[clientID].find(gamestateID) != clientListTemp_[clientID].end() ); 146 147 for(itvec = clientListTemp_[clientID][gamestateID].begin(); itvec != clientListTemp_[clientID][gamestateID].end(); itvec++) 144 assert( clientListTemp_[clientID].find(gamestateID) != clientListTemp_[clientID].end() ); 145 146 // shortcut for maps 147 std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID]; 148 std::map<unsigned int, std::list<obj> >& objectListTemp = clientListTemp_[clientID]; 149 150 for(itvec = objectListTemp[gamestateID].begin(); itvec != objectListTemp[gamestateID].end(); itvec++) 148 151 { 149 if( clientListPerm_[clientID].find((*itvec).objID) != clientListPerm_[clientID].end()) // check whether the obj already exists in our lists150 { 151 clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID;152 clientListPerm_[clientID][(*itvec).objID].objValueSched = 0; //set scheduling value back152 if(objectListPerm.find((*itvec).objID) != objectListPerm.end()) // check whether the obj already exists in our lists 153 { 154 objectListPerm[(*itvec).objID].objCurGS = gamestateID; 155 objectListPerm[(*itvec).objID].objValueSched = 0; //set scheduling value back 153 156 } 154 157 else 155 158 { 156 159 assert(0); 157 clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID;158 clientListPerm_[clientID][(*itvec).objID].objID = (*itvec).objID;159 clientListPerm_[clientID][(*itvec).objID].objCreatorID = (*itvec).objCreatorID;160 clientListPerm_[clientID][(*itvec).objID].objSize = (*itvec).objSize;160 objectListPerm[(*itvec).objID].objCurGS = gamestateID; 161 objectListPerm[(*itvec).objID].objID = (*itvec).objID; 162 objectListPerm[(*itvec).objID].objCreatorID = (*itvec).objCreatorID; 163 objectListPerm[(*itvec).objID].objSize = (*itvec).objSize; 161 164 } 162 165 } 163 166 // remove temporary list (with acked objects) from the map 164 clientListTemp_[clientID].erase( clientListTemp_[clientID].find(gamestateID) );167 objectListTemp.erase( objectListTemp.find(gamestateID) ); 165 168 } 166 169 … … 176 179 { 177 180 std::map<unsigned int,std::map<unsigned int, objInfo> >::iterator itperm;//iterator clientListPerm over clientIDs 178 // itperm = (clientListPerm_).find(clientID);179 // assert(itperm != clientListPerm_.end() );180 181 unsigned int gsid=GAMESTATEID_INITIAL, gsdiff=currentGamestateID, prioperm=Synchronisable::getSynchronisable(objinf.objID)->getPriority(), priomom=0; 181 182 clientListPerm_[clientID][objinf.objID] = objInfo(objinf.objID, objinf.objCreatorID,gsid,gsdiff, objinf.objSize,prioperm,priomom); 182 // itperm->second.insert(std::pair<unsigned int, objInfo>(objid,objinf));183 // permObjPrio_.insert(objid, objinf.objValuePerm);184 183 } 185 184 … … 188 187 * takes the shortened list which will be sent to the gsmanager and puts the *info into clientListTemp 189 188 */ 190 void TrafficControl::updateClientListTemp(std::list<obj> *list)191 { 192 clientListTemp_[currentClientID][currentGamestateID] = std::list<obj>( *list);189 void TrafficControl::updateClientListTemp(std::list<obj>& list) 190 { 191 clientListTemp_[currentClientID][currentGamestateID] = std::list<obj>(list); 193 192 } 194 193 … … 197 196 *takes the current list that has to be returned to the gsmanager and shortens it in criteria of bandwidth of clientID(XY) 198 197 */ 199 void TrafficControl::cut(std::list<obj> *list, unsigned int targetsize)198 void TrafficControl::cut(std::list<obj>& list, unsigned int targetsize) 200 199 { 201 200 unsigned int size=0; 202 201 std::list<obj>::iterator itvec, ittemp; 203 assert(!list ->empty());204 for(itvec = list ->begin(); itvec != list->end();)202 assert(!list.empty()); 203 for(itvec = list.begin(); itvec != list.end();) 205 204 { 206 205 assert( (*itvec).objSize < 1000); … … 213 212 { 214 213 clientListPerm_[currentClientID][(*itvec).objID].objValueSched += SCHED_PRIORITY_OFFSET; // NOTE: SCHED_PRIORITY_OFFSET is negative 215 list->erase(itvec++); 214 list.erase(itvec, list.end()); 215 break; 216 216 } 217 217 // printList(list, currentClientID); 218 218 } 219 assert(!list ->empty());219 assert(!list.empty()); 220 220 } 221 221 … … 224 224 *evaluateList evaluates whether new obj are there, whether there are things to be updatet and manipulates all this. 225 225 */ 226 void TrafficControl::evaluateList(unsigned int clientID, std::list<obj> *list)226 void TrafficControl::evaluateList(unsigned int clientID, std::list<obj>& list) 227 227 { 228 228 … … 232 232 //if listToProcess contains new Objects, add them to clientListPerm 233 233 std::list<obj>::iterator itvec; 234 for( itvec=list->begin(); itvec != list->end(); itvec++) 234 235 std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID]; 236 237 for( itvec=list.begin(); itvec != list.end(); itvec++) 235 238 { 236 if ( clientListPerm_[clientID].find( (*itvec).objID) != clientListPerm_[clientID].end() )239 if ( objectListPerm.find( (*itvec).objID) != objectListPerm.end() ) 237 240 { 238 241 // we already have the object in our map 239 242 //obj bleibt in liste und permanente prio wird berechnet 240 clientListPerm_[clientID][(*itvec).objID].objDiffGS = currentGamestateID - clientListPerm_[clientID][(*itvec).objID].objCurGS;243 objectListPerm[(*itvec).objID].objDiffGS = currentGamestateID - objectListPerm[(*itvec).objID].objCurGS; 241 244 continue;//check next objId 242 245 } … … 254 257 //sort copied list according to priorities 255 258 // use boost bind here because we need to pass a memberfunction to stl sort 256 list->sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) ); 259 // sort( list.begin(), list.end(), boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) ); 260 list.sort( boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) ); 261 262 // list.sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) ); 257 263 258 264 //now we check, that the creator of an object always exists on a client 259 265 std::list<obj>::iterator itcreator; 260 for(itvec = list ->begin(); itvec != list->end(); itvec++)266 for(itvec = list.begin(); itvec != list.end(); itvec++) 261 267 { 262 268 fixCreatorDependencies(itvec, list, clientID); … … 266 272 // printList(list, clientID); 267 273 cut(list, targetSize); 268 269 274 //now sort again after objDataOffset 270 list->sort(boost::bind(&TrafficControl::dataSort, this, _1, _2) ); 275 // sort(list.begin(), list.end(), boost::bind(&TrafficControl::dataSort, this, _1, _2) ); 276 list.sort( boost::bind(&TrafficControl::dataSort, this, _1, _2) ); 271 277 } 272 278 //diese Funktion updateClientList muss noch gemacht werden … … 275 281 } 276 282 277 void TrafficControl::printList(std::list<obj> *list, unsigned int clientID)283 void TrafficControl::printList(std::list<obj>& list, unsigned int clientID) 278 284 { 279 285 std::list<obj>::iterator it; 280 286 COUT(0) << "=========== Objectlist ===========" << endl; 281 for( it=list ->begin(); it!=list->end(); it++)287 for( it=list.begin(); it!=list.end(); it++) 282 288 COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << " size: " << (*it).objSize << endl; 283 289 } 284 290 285 void TrafficControl::fixCreatorDependencies(std::list<obj>::iterator it1, std::list<obj> *list, unsigned int clientID)291 void TrafficControl::fixCreatorDependencies(std::list<obj>::iterator it1, std::list<obj>& list, unsigned int clientID) 286 292 { 287 293 if ( (*it1).objCreatorID == OBJECTID_UNKNOWN ) … … 290 296 return; 291 297 std::list<obj>::iterator it2, it3=it1; 292 for( it2 = ++it3; it2 != list ->end(); it2++ )298 for( it2 = ++it3; it2 != list.end(); it2++ ) 293 299 { 294 300 if( (*it2).objID == (*it1).objCreatorID ) 295 301 { 296 it3 = list ->insert(it1, *it2); //insert creator before it1297 list ->erase(it2);302 it3 = list.insert(it1, *it2); //insert creator before it1 303 list.erase(it2); 298 304 // printList(list, clientID); 299 305 fixCreatorDependencies( it3, list, clientID );
Note: See TracChangeset
for help on using the changeset viewer.