Changeset 2773 for code/trunk/src
- Timestamp:
- Mar 11, 2009, 4:06:31 PM (16 years ago)
- Location:
- code/trunk/src
- Files:
-
- 1 added
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/core/input/ExtendedInputState.cc
r1887 r2773 35 35 #include "ExtendedInputState.h" 36 36 37 #include < assert.h>37 #include <cassert> 38 38 #include "util/Debug.h" 39 39 -
code/trunk/src/network/Client.cc
r2662 r2773 40 40 41 41 #include <cassert> 42 #include <enet/enet.h> 42 43 43 44 #include "Client.h" -
code/trunk/src/network/Client.h
r2171 r2773 50 50 #include "ClientConnection.h" 51 51 #include "GamestateClient.h" 52 //#include "NetworkFrameListener.h"53 54 52 55 53 … … 81 79 82 80 private: 81 Client(const Client& copy); // not used 83 82 virtual bool isServer_(){return false;} 84 83 -
code/trunk/src/network/ClientConnection.cc
r2662 r2773 40 40 #include "ClientConnection.h" 41 41 42 #include <enet/enet.h> 42 43 #include <iostream> 43 44 // boost.thread library for multithreading support 44 45 #include <boost/thread/thread.hpp> 45 46 #include <boost/bind.hpp> 47 #include <boost/thread/recursive_mutex.hpp> 46 48 47 49 #include "util/Sleep.h" … … 52 54 //static boost::thread_group network_threads; 53 55 54 boost::recursive_mutex ClientConnection::enet_mutex_;56 static boost::recursive_mutex enet_mutex_g; 55 57 56 58 ClientConnection::ClientConnection(int port, const std::string& address) { 57 59 quit=false; 58 60 server=NULL; 59 enet_address_set_host(&serverAddress, address.c_str()); 60 serverAddress.port = port; 61 serverAddress = new ENetAddress(); 62 enet_address_set_host(serverAddress, address.c_str()); 63 serverAddress->port = port; 61 64 established=false; 62 65 } … … 65 68 quit=false; 66 69 server=NULL; 67 enet_address_set_host(&serverAddress, address); 68 serverAddress.port = port; 70 serverAddress = new ENetAddress(); 71 enet_address_set_host(serverAddress, address); 72 serverAddress->port = port; 69 73 established=false; 70 74 } … … 80 84 if(established) 81 85 closeConnection(); 86 delete serverAddress; // surely was created 82 87 } 83 88 … … 116 121 return false; 117 122 } 118 boost::recursive_mutex::scoped_lock lock(enet_mutex_ );123 boost::recursive_mutex::scoped_lock lock(enet_mutex_g); 119 124 if(enet_peer_send(server, 0, packet)<0) 120 125 return false; … … 126 131 if(server==NULL) 127 132 return false; 128 boost::recursive_mutex::scoped_lock lock(enet_mutex_ );133 boost::recursive_mutex::scoped_lock lock(enet_mutex_g); 129 134 enet_host_flush(client); 130 135 lock.unlock(); … … 137 142 ENetEvent *event; 138 143 { 139 boost::recursive_mutex::scoped_lock lock(enet_mutex_ );144 boost::recursive_mutex::scoped_lock lock(enet_mutex_g); 140 145 enet_initialize(); 141 146 client = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, 0, 0); … … 158 163 //std::cout << "connection loop" << std::endl; 159 164 { 160 boost::recursive_mutex::scoped_lock lock(enet_mutex_ );165 boost::recursive_mutex::scoped_lock lock(enet_mutex_g); 161 166 if(enet_host_service(client, event, NETWORK_CLIENT_WAIT_TIME)<0){ 162 167 // we should never reach this point … … 192 197 if(!disconnectConnection()) 193 198 // if disconnecting failed destroy conn. 194 boost::recursive_mutex::scoped_lock lock(enet_mutex_ );199 boost::recursive_mutex::scoped_lock lock(enet_mutex_g); 195 200 enet_peer_reset(server); 196 201 return; … … 199 204 bool ClientConnection::disconnectConnection() { 200 205 ENetEvent event; 201 boost::recursive_mutex::scoped_lock lock(enet_mutex_ );206 boost::recursive_mutex::scoped_lock lock(enet_mutex_g); 202 207 enet_peer_disconnect(server, 0); 203 208 while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME) > 0){ … … 220 225 ENetEvent event; 221 226 // connect to peer (server is type ENetPeer*) 222 boost::recursive_mutex::scoped_lock lock(enet_mutex_ );223 server = enet_host_connect(client, &serverAddress, NETWORK_CLIENT_CHANNELS);227 boost::recursive_mutex::scoped_lock lock(enet_mutex_g); 228 server = enet_host_connect(client, serverAddress, NETWORK_CLIENT_CHANNELS); 224 229 if(server==NULL) { 225 230 COUT(2) << "ClientConnection: server == NULL" << std::endl; -
code/trunk/src/network/ClientConnection.h
r2756 r2773 44 44 45 45 #include <string> 46 #ifndef WIN32_LEAN_AND_MEAN47 # define WIN32_LEAN_AND_MEAN48 #endif49 #define NOMINMAX // required to stop windows.h screwing up std::min definition50 #include <enet/enet.h>51 #include <boost/thread/recursive_mutex.hpp>52 46 #include "PacketBuffer.h" 53 47 … … 84 78 bool isConnected(){return established;} 85 79 private: 80 ClientConnection(const ClientConnection& copy); // not used 86 81 bool processData(ENetEvent *event); 87 82 // implementation of the listener … … 93 88 // enet stuff 94 89 ENetHost *client; 95 ENetAddress serverAddress;90 ENetAddress *serverAddress; 96 91 // quit-variable (communication with threads) 97 92 bool quit; … … 100 95 ENetPeer *server; 101 96 boost::thread *receiverThread_; 102 103 static boost::recursive_mutex enet_mutex_; 104 }; 97 }; 105 98 106 99 -
code/trunk/src/network/ClientInformation.cc
r2662 r2773 41 41 #include "ClientInformation.h" 42 42 43 #include <enet/enet.h> 43 44 #include <iostream> //debug 44 45 … … 162 163 } 163 164 164 enet_uint32ClientInformation::getRTT(){165 uint32_t ClientInformation::getRTT(){ 165 166 return this->peer_->roundTripTime; 166 167 } -
code/trunk/src/network/ClientInformation.h
r2756 r2773 43 43 #include "NetworkPrereqs.h" 44 44 45 #ifndef WIN32_LEAN_AND_MEAN46 # define WIN32_LEAN_AND_MEAN47 #endif48 #define NOMINMAX // required to stop windows.h screwing up std::min definition49 #include <enet/enet.h>50 #include <boost/thread/recursive_mutex.hpp>51 52 53 45 // WATCH OUT: THE CLIENTINFORMATION LIST IS NOT THREADSAFE ANYMORE 54 46 … … 87 79 void addFailure(); 88 80 void resetFailures(); 89 enet_uint32getRTT();81 uint32_t getRTT(); 90 82 double getPacketLoss(); 91 83 -
code/trunk/src/network/ConnectionManager.cc
r2759 r2773 40 40 #include "ConnectionManager.h" 41 41 42 #include <enet/enet.h> 42 43 #include <iostream> 43 #include < assert.h>44 #include <cassert> 44 45 // boost.thread library for multithreading support 45 46 #include <boost/thread/thread.hpp> 46 47 #include <boost/bind.hpp> 48 #include <boost/thread/recursive_mutex.hpp> 47 49 48 50 #include "util/Math.h" … … 65 67 { 66 68 //boost::thread_group network_threads; 69 static boost::recursive_mutex enet_mutex_g; 67 70 68 71 ConnectionManager *ConnectionManager::instance_=0; … … 72 75 instance_=this; 73 76 quit=false; 74 bindAddress .host = ENET_HOST_ANY;75 bindAddress .port = NETWORK_PORT;76 }77 boost::recursive_mutex ConnectionManager::enet_mutex;77 bindAddress = new ENetAddress(); 78 bindAddress->host = ENET_HOST_ANY; 79 bindAddress->port = NETWORK_PORT; 80 } 78 81 79 82 ConnectionManager::ConnectionManager(int port){ … … 81 84 instance_=this; 82 85 quit=false; 83 bindAddress.host = ENET_HOST_ANY; 84 bindAddress.port = port; 86 bindAddress = new ENetAddress(); 87 bindAddress->host = ENET_HOST_ANY; 88 bindAddress->port = port; 85 89 } 86 90 … … 89 93 instance_=this; 90 94 quit=false; 91 enet_address_set_host (& bindAddress, address.c_str()); 92 bindAddress.port = NETWORK_PORT; 95 bindAddress = new ENetAddress(); 96 enet_address_set_host (bindAddress, address.c_str()); 97 bindAddress->port = NETWORK_PORT; 93 98 } 94 99 … … 97 102 instance_=this; 98 103 quit=false; 99 enet_address_set_host (& bindAddress, address); 100 bindAddress.port = NETWORK_PORT; 104 bindAddress = new ENetAddress(); 105 enet_address_set_host (bindAddress, address); 106 bindAddress->port = NETWORK_PORT; 101 107 } 102 108 … … 105 111 quitListener(); 106 112 instance_=0; 113 delete bindAddress; 107 114 } 108 115 … … 132 139 133 140 bool ConnectionManager::addPacket(ENetPacket *packet, ENetPeer *peer) { 134 boost::recursive_mutex::scoped_lock lock( ConnectionManager::enet_mutex);141 boost::recursive_mutex::scoped_lock lock(enet_mutex_g); 135 142 if(enet_peer_send(peer, NETWORK_DEFAULT_CHANNEL, packet)!=0) 136 143 return false; … … 150 157 if(!instance_) 151 158 return false; 152 boost::recursive_mutex::scoped_lock lock( ConnectionManager::enet_mutex);159 boost::recursive_mutex::scoped_lock lock(enet_mutex_g); 153 160 for(ClientInformation *i=ClientInformation::getBegin()->next(); i!=0; i=i->next()){ 154 161 COUT(3) << "adding broadcast packet for client: " << i->getID() << std::endl; … … 163 170 if(server==NULL || !instance_) 164 171 return false; 165 boost::recursive_mutex::scoped_lock lock( ConnectionManager::enet_mutex);172 boost::recursive_mutex::scoped_lock lock(enet_mutex_g); 166 173 enet_host_flush(server); 167 174 lock.unlock(); … … 174 181 atexit(enet_deinitialize); 175 182 { //scope of the mutex 176 boost::recursive_mutex::scoped_lock lock( ConnectionManager::enet_mutex);183 boost::recursive_mutex::scoped_lock lock(enet_mutex_g); 177 184 enet_initialize(); 178 server = enet_host_create( &bindAddress, NETWORK_MAX_CONNECTIONS, 0, 0);185 server = enet_host_create(bindAddress, NETWORK_MAX_CONNECTIONS, 0, 0); 179 186 lock.unlock(); 180 187 } … … 188 195 while(!quit){ 189 196 { //mutex scope 190 boost::recursive_mutex::scoped_lock lock( ConnectionManager::enet_mutex);197 boost::recursive_mutex::scoped_lock lock(enet_mutex_g); 191 198 if(enet_host_service(server, event, NETWORK_WAIT_TIMEOUT)<0){ 192 199 // we should never reach this point … … 216 223 // if we're finishied, destroy server 217 224 { 218 boost::recursive_mutex::scoped_lock lock( ConnectionManager::enet_mutex);225 boost::recursive_mutex::scoped_lock lock(enet_mutex_g); 219 226 enet_host_destroy(server); 220 227 lock.unlock(); … … 230 237 while(temp!=0){ 231 238 { 232 boost::recursive_mutex::scoped_lock lock( ConnectionManager::enet_mutex);239 boost::recursive_mutex::scoped_lock lock(enet_mutex_g); 233 240 enet_peer_disconnect(temp->getPeer(), 0); 234 241 lock.unlock(); … … 238 245 //bugfix: might be the reason why server crashes when clients disconnects 239 246 temp = ClientInformation::getBegin()->next(); 240 boost::recursive_mutex::scoped_lock lock( ConnectionManager::enet_mutex);247 boost::recursive_mutex::scoped_lock lock(enet_mutex_g); 241 248 while( temp!=0 && enet_host_service(server, &event, NETWORK_WAIT_TIMEOUT) >= 0){ 242 249 switch (event.type) … … 267 274 268 275 269 int ConnectionManager::getClientID(ENetPeer peer) {270 return getClientID( peer.address);271 } 272 273 int ConnectionManager::getClientID(ENetAddress address) {274 return ClientInformation::findClient( &address)->getID();276 int ConnectionManager::getClientID(ENetPeer* peer) { 277 return getClientID(&(peer->address)); 278 } 279 280 int ConnectionManager::getClientID(ENetAddress* address) { 281 return ClientInformation::findClient(address)->getID(); 275 282 } 276 283 … … 294 301 void ConnectionManager::disconnectClient(ClientInformation *client){ 295 302 { 296 boost::recursive_mutex::scoped_lock lock( ConnectionManager::enet_mutex);303 boost::recursive_mutex::scoped_lock lock(enet_mutex_g); 297 304 enet_peer_disconnect(client->getPeer(), 0); 298 305 lock.unlock(); -
code/trunk/src/network/ConnectionManager.h
r2759 r2773 45 45 #include <string> 46 46 #include <map> 47 // enet library for networking support48 #ifndef WIN32_LEAN_AND_MEAN49 # define WIN32_LEAN_AND_MEAN50 #endif51 #define NOMINMAX // required to stop windows.h screwing up std::min definition52 #include <enet/enet.h>53 #include <boost/thread/recursive_mutex.hpp>54 47 55 48 #include "PacketBuffer.h" … … 57 50 58 51 namespace boost { class thread; } 59 60 namespace std61 {62 bool operator<(ENetAddress a, ENetAddress b);63 }64 52 65 53 namespace orxonox … … 78 66 class _NetworkExport ConnectionManager{ 79 67 public: 80 static boost::recursive_mutex enet_mutex;81 68 ConnectionManager(); 82 69 ConnectionManager(int port); … … 96 83 97 84 private: 85 ConnectionManager(const ConnectionManager& copy); // not used 98 86 bool processData(ENetEvent *event); 99 87 void receiverThread(); 100 88 void disconnectClients(); 101 int getClientID(ENetPeer peer);102 int getClientID(ENetAddress address);89 int getClientID(ENetPeer* peer); 90 int getClientID(ENetAddress* address); 103 91 ENetPeer *getClientPeer(int clientID); 104 92 PacketBuffer buffer; 105 93 106 94 ENetHost *server; 107 ENetAddress bindAddress;95 ENetAddress *bindAddress; 108 96 109 97 bool quit; // quit-variable (communication with threads) -
code/trunk/src/network/GamestateHandler.cc
r2171 r2773 1 #include < assert.h>1 #include <cassert> 2 2 3 3 #include "GamestateHandler.h" -
code/trunk/src/network/Host.cc
r2171 r2773 27 27 */ 28 28 29 #include < assert.h>29 #include <cassert> 30 30 31 31 #include "Host.h" -
code/trunk/src/network/NetworkPrereqs.h
r2710 r2773 69 69 // Forward declarations 70 70 //----------------------------------------------------------------------- 71 72 // from ENet 73 struct _ENetPeer; 74 typedef _ENetPeer ENetPeer; 75 struct _ENetPacket; 76 typedef _ENetPacket ENetPacket; 77 struct _ENetEvent; 78 typedef _ENetEvent ENetEvent; 79 struct _ENetHost; 80 typedef _ENetHost ENetHost; 81 struct _ENetAddress; 82 typedef _ENetAddress ENetAddress; 83 71 84 namespace orxonox 72 85 { -
code/trunk/src/network/PacketBuffer.cc
r2171 r2773 33 33 #include "PacketBuffer.h" 34 34 35 #include <enet/enet.h> 35 36 #include <iostream> 36 37 #include <queue> … … 38 39 #include <boost/bind.hpp> 39 40 #include <boost/thread/mutex.hpp> 41 #include <boost/thread/recursive_mutex.hpp> 40 42 41 43 namespace orxonox 42 44 { 43 boost::recursive_mutex PacketBuffer::mutex_;45 static boost::recursive_mutex packetBuffer_mutex_g; 44 46 45 47 PacketBuffer::PacketBuffer() { … … 52 54 53 55 bool PacketBuffer::push(ENetEvent *ev) { 54 boost::recursive_mutex::scoped_lock lock( mutex_);56 boost::recursive_mutex::scoped_lock lock(packetBuffer_mutex_g); 55 57 //std::cout << "event size inside packetbuffer " << ev->packet->dataLength << std::endl; 56 58 // if(closed) … … 86 88 87 89 ENetEvent *PacketBuffer::pop(){ 88 boost::recursive_mutex::scoped_lock lock( mutex_);90 boost::recursive_mutex::scoped_lock lock(packetBuffer_mutex_g); 89 91 //std::cout << "packetbuffer pop(address)" << std::endl; 90 92 if(first!=NULL /*&& !closed*/){ … … 106 108 107 109 /*ENetPacket *PacketBuffer::pop(ENetAddress &address) { 108 boost::recursive_mutex::scoped_lock lock( mutex_);110 boost::recursive_mutex::scoped_lock lock(packetBuffer_mutex_g); 109 111 //std::cout << "packetbuffer pop(address)" << std::endl; 110 112 if(first!=NULL ){ -
code/trunk/src/network/PacketBuffer.h
r2756 r2773 44 44 #include "NetworkPrereqs.h" 45 45 46 #ifndef WIN32_LEAN_AND_MEAN47 # define WIN32_LEAN_AND_MEAN48 #endif49 #define NOMINMAX // required to stop windows.h screwing up std::min definition50 #include <enet/enet.h>51 #include <boost/thread/recursive_mutex.hpp>52 53 46 namespace orxonox 54 47 { … … 82 75 QueueItem *last; 83 76 bool closed; 84 static boost::recursive_mutex mutex_;85 77 }; 86 78 -
code/trunk/src/network/Server.cc
r2662 r2773 41 41 #include "Server.h" 42 42 43 #include <enet/enet.h> 43 44 #include <iostream> 44 45 #include <cassert> … … 57 58 #include "packet/Welcome.h" 58 59 #include "packet/DeleteObjects.h" 59 #include <util/Convert.h>60 #include "util/Convert.h" 60 61 #include "ChatListener.h" 61 62 -
code/trunk/src/network/packet/Chat.cc
r2171 r2773 28 28 29 29 #include "Chat.h" 30 #include <assert.h> 30 31 #include <enet/enet.h> 32 #include <cassert> 31 33 #include "network/Host.h" 32 34 -
code/trunk/src/network/packet/ClassID.cc
r2759 r2773 30 30 31 31 #include "ClassID.h" 32 #include <enet/enet.h> 32 33 #include "core/CoreIncludes.h" 33 34 #include "core/Factory.h" 34 35 #include <cstring> 35 36 #include <string> 36 #include < assert.h>37 #include <cassert> 37 38 #include <map> 38 39 #include <queue> -
code/trunk/src/network/packet/DeleteObjects.cc
r2756 r2773 29 29 30 30 #include "DeleteObjects.h" 31 #ifndef WIN32_LEAN_AND_MEAN32 # define WIN32_LEAN_AND_MEAN33 #endif34 #define NOMINMAX // required to stop windows.h screwing up std::min definition35 31 #include <enet/enet.h> 36 32 #include "network/synchronisable/Synchronisable.h" 37 33 #include "core/CoreIncludes.h" 38 #include < assert.h>34 #include <cassert> 39 35 40 36 namespace orxonox { -
code/trunk/src/network/packet/Gamestate.cc
r2759 r2773 28 28 29 29 #include "Gamestate.h" 30 #include <enet/enet.h> 31 #include <zlib.h> 32 #include <cassert> 30 33 #include "../GamestateHandler.h" 31 34 #include "../synchronisable/Synchronisable.h" … … 35 38 #include "core/Iterator.h" 36 39 37 #include <zlib.h>38 #include <cassert>39 40 40 41 -
code/trunk/src/network/packet/Packet.cc
r2756 r2773 31 31 32 32 #include <cassert> 33 #ifndef WIN32_LEAN_AND_MEAN34 # define WIN32_LEAN_AND_MEAN35 #endif36 #define NOMINMAX // required to stop windows.h screwing up std::min definition37 33 #include <enet/enet.h> 38 34 #include <boost/bind.hpp> 35 #include <boost/thread/recursive_mutex.hpp> 39 36 40 37 #include "network/ConnectionManager.h" … … 58 55 59 56 std::map<size_t, Packet *> Packet::packetMap_; 60 boost::recursive_mutex Packet::packetMap_mutex; 57 //! Static mutex for any packetMap_ access 58 static boost::recursive_mutex packetMap_mutex_g; 61 59 62 60 Packet::Packet(){ … … 142 140 // Assures we don't create a packet and destroy it right after in another thread 143 141 // without having a reference in the packetMap_ 144 boost::recursive_mutex::scoped_lock lock( Packet::packetMap_mutex);142 boost::recursive_mutex::scoped_lock lock(packetMap_mutex_g); 145 143 packetMap_[(size_t)(void*)enetPacket_] = this; 146 144 } … … 217 215 */ 218 216 void Packet::deletePacket(ENetPacket *enetPacket){ 219 boost::recursive_mutex::scoped_lock lock( Packet::packetMap_mutex);217 boost::recursive_mutex::scoped_lock lock(packetMap_mutex_g); 220 218 // Get our Packet from a gloabal map with all Packets created in the send() method of Packet. 221 219 std::map<size_t, Packet*>::iterator it = packetMap_.find((size_t)enetPacket); -
code/trunk/src/network/packet/Packet.h
r2756 r2773 32 32 33 33 #include <map> 34 #ifndef WIN32_LEAN_AND_MEAN35 # define WIN32_LEAN_AND_MEAN36 #endif37 #define NOMINMAX // required to stop windows.h screwing up std::min definition38 #include <enet/enet.h>39 #include <boost/thread/recursive_mutex.hpp>40 34 41 35 namespace orxonox { … … 72 66 virtual unsigned int getSize() const =0; 73 67 virtual bool process()=0; 74 enet_uint32getFlags()68 uint32_t getFlags() 75 69 { return flags_; } 76 70 int getClientID() … … 84 78 Packet(uint8_t *data, unsigned int clientID); 85 79 // Packet(ENetPacket *packet, ENetPeer *peer); 86 enet_uint32flags_;80 uint32_t flags_; 87 81 unsigned int clientID_; 88 82 ENUM::Direction packetDirection_; … … 96 90 private: 97 91 static std::map<size_t, Packet *> packetMap_; 98 //! Static mutex for any packetMap_ access99 static boost::recursive_mutex packetMap_mutex;100 92 ENetPacket *enetPacket_; 101 93 }; -
code/trunk/src/network/packet/Welcome.cc
r2662 r2773 31 31 32 32 #include "Welcome.h" 33 #include <enet/enet.h> 34 #include <cassert> 33 35 #include "network/Host.h" 34 36 #include "network/synchronisable/Synchronisable.h" 35 37 #include "core/CoreIncludes.h" 36 #include <assert.h>37 38 38 39 namespace orxonox { -
code/trunk/src/network/synchronisable/Synchronisable.cc
r2759 r2773 34 34 #include <string> 35 35 #include <iostream> 36 #include < assert.h>36 #include <cassert> 37 37 38 38 #include "core/CoreIncludes.h" -
code/trunk/src/network/synchronisable/Synchronisable.h
r2759 r2773 39 39 #include "util/mbool.h" 40 40 #include "core/OrxonoxClass.h" 41 // TODO: this has to be removed42 // #include <OgreLight.h>43 // #include "OrxonoxPrereqs.h"44 // ============================45 41 #include "NetworkCallback.h" 46 42 #include "SynchronisableVariable.h" -
code/trunk/src/util/CMakeLists.txt
r2710 r2773 47 47 OutputHandler.cc 48 48 SignalHandler.cc 49 Sleep.cc 49 50 String.cc 50 51 SubString.cc -
code/trunk/src/util/Sleep.h
r2710 r2773 30 30 @file 31 31 @brief 32 Functions for using sleep() and usleep() underwindows.32 Functions for using sleep() and usleep() on windows. 33 33 */ 34 34 … … 38 38 #include "UtilPrereqs.h" 39 39 40 #ifdef ORXONOX_PLATFORM_WINDOWS41 #include <winbase.h>42 43 40 namespace orxonox 44 41 { 45 inline void usleep(DWORD dwMicroseconds) 46 { 47 Sleep(dwMicroseconds / 1000); 48 } 49 50 inline void msleep(DWORD dwMilliseconds) 51 { 52 Sleep(dwMilliseconds); 53 } 54 55 inline void sleep(DWORD dwSeconds) 56 { 57 Sleep(dwSeconds * 1000); 58 } 42 _UtilExport void usleep(unsigned long microseconds); 43 _UtilExport void msleep(unsigned long milliseconds); 44 _UtilExport void sleep (unsigned long seconds); 59 45 } 60 46 61 #else /* Linux/Apple */62 63 #include <unistd.h>64 65 namespace orxonox66 {67 inline void usleep(unsigned long usec)68 {69 ::usleep(usec);70 }71 inline void msleep(unsigned long msec)72 {73 ::usleep(msec * 1000);74 }75 inline void sleep(unsigned long sec)76 {77 ::usleep(sec * 1000000);78 }79 }80 81 #endif82 83 47 #endif /* _Sleep_H__ */
Note: See TracChangeset
for help on using the changeset viewer.