Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 23, 2008, 11:15:09 PM (15 years ago)
Author:
rgrieder
Message:

Merged revisions 2377-2382 to bugger from presentation.

File:
1 edited

Legend:

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

    r2531 r2532  
    3030
    3131#include "synchronisable/Synchronisable.h"
     32#include "core/ConfigValueIncludes.h"
    3233
    3334#include <cassert>
     
    6768        TrafficControl::TrafficControl()
    6869        {
     70    RegisterRootObject(TrafficControl);
    6971          assert(instance_==0);
    7072          instance_=this;
    71     targetSize = 1000;//5000bytes
     73//     targetSize = 2500;//5000bytes
     74    SetConfigValue ( targetSize, 28000./25. );
    7275        }
    7376       
     
    127130          return;
    128131        }
    129        
    130         void TrafficControl::processAck(unsigned int clientID, unsigned int gamestateID)
     132 
     133  TrafficControl *TrafficControl::getInstance()
     134  {
     135    assert(instance_);
     136    return instance_;
     137  }
     138       
     139        void TrafficControl::ack(unsigned int clientID, unsigned int gamestateID)
    131140        {
    132141          std::list<obj>::iterator itvec;  // iterator to iterate through the acked objects
     
    141150      if(clientListPerm_[clientID].find((*itvec).objID) != clientListPerm_[clientID].end()) // check whether the obj already exists in our lists
    142151      {
    143         clientListPerm_[clientID][(*itvec).objID].objID = gamestateID;
     152        clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID;
     153        clientListPerm_[clientID][(*itvec).objID].objValueSched = 0; //set scheduling value back
    144154      }
    145155      else
    146156      {
     157        assert(0);
    147158        clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID;
    148159        clientListPerm_[clientID][(*itvec).objID].objID = (*itvec).objID;
     
    225236//     for(itvec = list.begin(); itvec!=list.end(), itvec++)
    226237//     {
    227 //       ittempgs.insert(itvec);
     238//       ittempgs.insert(itvec);static
    228239//     }
    229240  }
     
    236247  {
    237248    unsigned int size=0;
    238     std::list<obj>::iterator itvec;
     249    std::list<obj>::iterator itvec, ittemp;
    239250    assert(!list->empty());
    240     itvec = list->begin();
    241     for(itvec = list->begin(); itvec != list->end() && size<targetsize; itvec++)
     251    for(itvec = list->begin(); itvec != list->end();)
    242252    {
    243253      assert( (*itvec).objSize < 1000);
    244       if ( size + (*itvec).objSize < targetsize )
    245       {
     254//       COUT(0) << "==targetsize==  " << targetsize << endl;
     255      if ( ( size + (*itvec).objSize ) < targetsize )
     256      {
     257//         COUT(0) << "no cut" << endl;
    246258        size += (*itvec).objSize;//objSize is given in bytes
     259        ++itvec;
    247260      }
    248261      else
    249262      {
    250         clientListPerm_[currentClientID][(*itvec).objID].objValueSched -= SCHED_PRIORITY_OFFSET;
     263//         COUT(0) << "cut" << endl;
     264        clientListPerm_[currentClientID][(*itvec).objID].objValueSched += SCHED_PRIORITY_OFFSET; // NOTE: SCHED_PRIORITY_OFFSET is negative
     265//         ittemp = itvec;
    251266        list->erase(itvec++);
    252       }
     267//         itvec = ittemp;
     268      }
     269//       printList(list, currentClientID);
    253270    }
    254271    assert(!list->empty());
     
    339356   
    340357    //now we check, that the creator of an object always exists on a client
    341     printList(list, clientID);
     358//     printList(list, clientID);
    342359    std::list<obj>::iterator itcreator;
    343360    for(itvec = list->begin(); itvec != list->end(); itvec++)
     
    348365    //now the cutting, work the same obj out in processobjectlist and copiedlist, compression rate muss noch festgelegt werden.
    349366    cut(list, targetSize);
    350     printList(list, clientID);
     367//     printList(list, clientID);
    351368    //diese Funktion updateClientList muss noch gemacht werden
    352369    updateClientListTemp(list);
     
    359376    COUT(0) << "=========== Objectlist ===========" << endl;
    360377    for( it=list->begin(); it!=list->end(); it++)
    361       COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << endl;
     378      COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << " size: " << (*it).objSize << endl;
    362379  }
    363380 
Note: See TracChangeset for help on using the changeset viewer.