Changeset 2164 for code/branches/objecthierarchy/src/network/packet
- Timestamp:
- Nov 9, 2008, 2:39:15 PM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/network/packet
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/network/packet/Packet.cc
r2132 r2164 54 54 55 55 std::map<size_t, Packet *> Packet::packetMap_; 56 boost::recursive_mutex Packet::packetMap_mutex; 56 57 57 58 Packet::Packet(){ … … 128 129 return false; 129 130 } 131 // Assures we don't create a packet and destroy it right after in another thread 132 // without having a reference in the packetMap_ 133 boost::recursive_mutex::scoped_lock lock(Packet::packetMap_mutex); 130 134 // We deliver ENet the data address so that it doesn't memcpy everything again. 131 135 // --> We have to delete data_ ourselves! … … 207 211 */ 208 212 void Packet::deletePacket(ENetPacket *enetPacket){ 213 boost::recursive_mutex::scoped_lock lock(Packet::packetMap_mutex); 209 214 // Get our Packet from a gloabal map with all Packets created in the send() method of Packet. 210 215 std::map<size_t, Packet*>::iterator it = packetMap_.find((size_t)enetPacket); … … 213 218 it->second->enetPacket_ = 0; 214 219 delete it->second; 215 //packetMap_.erase(it);220 packetMap_.erase(it); 216 221 COUT(4) << "PacketMap size: " << packetMap_.size() << std::endl; 217 222 } -
code/branches/objecthierarchy/src/network/packet/Packet.h
r2132 r2164 29 29 #define NETWORKPACKET_H 30 30 31 #include " ../NetworkPrereqs.h"31 #include "network/NetworkPrereqs.h" 32 32 33 33 #include <map> 34 34 #include <enet/enet.h> 35 #include <boost/thread/recursive_mutex.hpp> 35 36 36 37 #include "util/Integers.h" … … 93 94 private: 94 95 static std::map<size_t, Packet *> packetMap_; 96 //! Static mutex for any packetMap_ access 97 static boost::recursive_mutex packetMap_mutex; 95 98 ENetPacket *enetPacket_; 96 99 };
Note: See TracChangeset
for help on using the changeset viewer.