Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 22, 2009, 9:46:53 AM (15 years ago)
Author:
scheusso
Message:

trying to make some performance improvements in TrafficControl

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/netp3/src/network/TrafficControl.cc

    r2990 r3015  
    2121 *
    2222 *   Author:
    23  *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
     23 *      Oliver Scheuss <scheusso [at] ee.ethz.ch>
    2424 *   Co-authors:
    2525 *      ...
     
    121121
    122122
    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::vector<obj>& list)
     124        {
    126125          currentClientID=clientID;
    127126          currentGamestateID=gamestateID;
     
    138137        void TrafficControl::ack(unsigned int clientID, unsigned int gamestateID)
    139138        {
    140           std::list<obj>::iterator itvec;  // iterator to iterate through the acked objects
     139          std::vector<obj>::iterator itvec;  // iterator to iterate through the acked objects
    141140
    142141    //assertions to make sure the maps already exist
     
    176175        {
    177176          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() );
    180177    unsigned int gsid=GAMESTATEID_INITIAL, gsdiff=currentGamestateID, prioperm=Synchronisable::getSynchronisable(objinf.objID)->getPriority(), priomom=0;
    181178    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);
    184179        }
    185180
     
    188183  * takes the shortened list which will be sent to the gsmanager and puts the *info into clientListTemp
    189184  */
    190   void TrafficControl::updateClientListTemp(std::list<obj> *list)
    191   {
    192     clientListTemp_[currentClientID][currentGamestateID] = std::list<obj>(*list);
     185  void TrafficControl::updateClientListTemp(std::vector<obj>& list)
     186  {
     187    clientListTemp_[currentClientID][currentGamestateID] = std::vector<obj>(list);
    193188  }
    194189
     
    197192  *takes the current list that has to be returned to the gsmanager and shortens it in criteria of bandwidth of clientID(XY)
    198193  */
    199   void TrafficControl::cut(std::list<obj> *list, unsigned int targetsize)
     194  void TrafficControl::cut(std::vector<obj>& list, unsigned int targetsize)
    200195  {
    201196    unsigned int size=0;
    202     std::list<obj>::iterator itvec, ittemp;
    203     assert(!list->empty());
    204     for(itvec = list->begin(); itvec != list->end();)
     197    std::vector<obj>::iterator itvec, ittemp;
     198    assert(!list.empty());
     199    for(itvec = list.begin(); itvec != list.end();)
    205200    {
    206201      assert( (*itvec).objSize < 1000);
     
    213208      {
    214209        clientListPerm_[currentClientID][(*itvec).objID].objValueSched += SCHED_PRIORITY_OFFSET; // NOTE: SCHED_PRIORITY_OFFSET is negative
    215         list->erase(itvec++);
     210        list.erase(itvec++);
    216211      }
    217212//       printList(list, currentClientID);
    218213    }
    219     assert(!list->empty());
     214    assert(!list.empty());
    220215  }
    221216
     
    224219        *evaluateList evaluates whether new obj are there, whether there are things to be updatet and manipulates all this.
    225220        */
    226         void TrafficControl::evaluateList(unsigned int clientID, std::list<obj> *list)
     221        void TrafficControl::evaluateList(unsigned int clientID, std::vector<obj>& list)
    227222        {
    228223
     
    231226          //compare listToProcess vs clientListPerm
    232227    //if listToProcess contains new Objects, add them to clientListPerm
    233     std::list<obj>::iterator itvec;
    234           for( itvec=list->begin(); itvec != list->end(); itvec++)
     228    std::vector<obj>::iterator itvec;
     229          for( itvec=list.begin(); itvec != list.end(); itvec++)
    235230          {
    236231            if ( clientListPerm_[clientID].find( (*itvec).objID) != clientListPerm_[clientID].end() )
     
    254249      //sort copied list according to priorities
    255250      // 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) );
     251      sort( list.begin(), list.end(), boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
     252//       list.sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
    257253
    258254      //now we check, that the creator of an object always exists on a client
    259       std::list<obj>::iterator itcreator;
    260       for(itvec = list->begin(); itvec != list->end(); itvec++)
     255      std::vector<obj>::iterator itcreator;
     256      for(itvec = list.begin(); itvec != list.end(); itvec++)
    261257      {
    262258        fixCreatorDependencies(itvec, list, clientID);
     
    268264
    269265      //now sort again after objDataOffset
    270       list->sort(boost::bind(&TrafficControl::dataSort, this, _1, _2) );
     266      sort(list.begin(), list.end(), boost::bind(&TrafficControl::dataSort, this, _1, _2) );
    271267    }
    272268    //diese Funktion updateClientList muss noch gemacht werden
     
    275271  }
    276272
    277   void TrafficControl::printList(std::list<obj> *list, unsigned int clientID)
    278   {
    279     std::list<obj>::iterator it;
     273  void TrafficControl::printList(std::vector<obj>& list, unsigned int clientID)
     274  {
     275    std::vector<obj>::iterator it;
    280276    COUT(0) << "=========== Objectlist ===========" << endl;
    281     for( it=list->begin(); it!=list->end(); it++)
     277    for( it=list.begin(); it!=list.end(); it++)
    282278      COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << " size: " << (*it).objSize << endl;
    283279  }
    284280
    285   void TrafficControl::fixCreatorDependencies(std::list<obj>::iterator it1, std::list<obj> *list, unsigned int clientID)
     281  void TrafficControl::fixCreatorDependencies(std::vector<obj>::iterator it1, std::vector<obj>& list, unsigned int clientID)
    286282  {
    287283    if ( (*it1).objCreatorID == OBJECTID_UNKNOWN )
     
    289285    if( clientListPerm_[clientID][(*it1).objCreatorID].objCurGS != GAMESTATEID_INITIAL )
    290286      return;
    291     std::list<obj>::iterator it2, it3=it1;
    292     for( it2 = ++it3; it2 != list->end(); it2++ )
     287    std::vector<obj>::iterator it2, it3=it1;
     288    for( it2 = ++it3; it2 != list.end(); it2++ )
    293289    {
    294290      if( (*it2).objID == (*it1).objCreatorID )
    295291      {
    296         it3 = list->insert(it1, *it2); //insert creator before it1
    297         list->erase(it2);
     292        it3 = list.insert(it1, *it2); //insert creator before it1
     293        list.erase(it2);
    298294//         printList(list, clientID);
    299295        fixCreatorDependencies( it3, list, clientID );
Note: See TracChangeset for help on using the changeset viewer.