Changeset 188 for code/branches/network/src/network/PacketBuffer.cc
- Timestamp:
- Nov 7, 2007, 8:38:47 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/PacketBuffer.cc
r174 r188 13 13 } 14 14 15 bool PacketBuffer::push( PacketEnvelopepck){15 bool PacketBuffer::push(ENetPacket *pck){ 16 16 boost::mutex::scoped_lock lock(networkPacketBufferMutex); 17 // if(closed) 18 // return false; 17 19 // also works if fifo is null (queue empty) 18 20 // just to be sure last is really the last element 19 while(last!=NULL && last->next!=NULL) 20 last=last->next; 21 /*if(last!=NULL) 22 while(last->next!=NULL) 23 last=last->next;*/ 21 24 // first element? 22 25 if(first==NULL){ … … 25 28 last->next=NULL; 26 29 // change this!!!!!!! 27 last->packet = new PacketEnvelope; 28 last->packet->data = pck.data; 29 last->packet->length = pck.length; 30 } else { 30 last->packet = pck; 31 } else { 31 32 //insert a new element at the bottom 32 33 last->next = new QueueItem; … … 35 36 last->next=NULL; 36 37 // save the packet to the new element 37 // change this!!!!!!!! 38 last->packet = new PacketEnvelope; 39 last->packet->data = pck.data; 40 last->packet->length = pck.length; 38 last->packet = pck; 41 39 } 42 40 return true; 43 41 } 44 42 45 PacketEnvelopePacketBuffer::pop(){43 ENetPacket *PacketBuffer::pop(){ 46 44 boost::mutex::scoped_lock lock(networkPacketBufferMutex); 47 if(first!=NULL ){45 if(first!=NULL /*&& !closed*/){ 48 46 QueueItem *temp = first; 49 47 // get packet 50 PacketEnvelope *p =first->packet;48 ENetPacket *pck=first->packet; 51 49 // remove first element 52 50 first = first->next; 53 51 delete temp; 54 return *p;52 return pck; 55 53 } else{ 56 PacketEnvelope p = {0,0}; 57 return p; 54 return NULL; 58 55 } 59 56 }
Note: See TracChangeset
for help on using the changeset viewer.