Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2773


Ignore:
Timestamp:
Mar 11, 2009, 4:06:31 PM (15 years ago)
Author:
rgrieder
Message:

Removed all enet and boost includes from header files in the network library.

  • Reduces dependencies
  • Minimises problems with windows.h
  • Speeds up the compiling process a little bit (probably negligible)
  • Also removes ugly WIN32_LEAN_AND_MEAN declarations before every enet.h include in the network library.

Removed windows.h header from util/Sleep.h by adding Sleep.cc

Location:
code/trunk/src
Files:
1 added
26 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/core/input/ExtendedInputState.cc

    r1887 r2773  
    3535#include "ExtendedInputState.h"
    3636
    37 #include <assert.h>
     37#include <cassert>
    3838#include "util/Debug.h"
    3939
  • code/trunk/src/network/Client.cc

    r2662 r2773  
    4040
    4141#include <cassert>
     42#include <enet/enet.h>
    4243
    4344#include "Client.h"
  • code/trunk/src/network/Client.h

    r2171 r2773  
    5050#include "ClientConnection.h"
    5151#include "GamestateClient.h"
    52 //#include "NetworkFrameListener.h"
    53 
    5452
    5553
     
    8179
    8280  private:
     81    Client(const Client& copy); // not used
    8382    virtual bool isServer_(){return false;}
    8483
  • code/trunk/src/network/ClientConnection.cc

    r2662 r2773  
    4040#include "ClientConnection.h"
    4141
     42#include <enet/enet.h>
    4243#include <iostream>
    4344// boost.thread library for multithreading support
    4445#include <boost/thread/thread.hpp>
    4546#include <boost/bind.hpp>
     47#include <boost/thread/recursive_mutex.hpp>
    4648
    4749#include "util/Sleep.h"
     
    5254  //static boost::thread_group network_threads;
    5355
    54   boost::recursive_mutex ClientConnection::enet_mutex_;
     56  static boost::recursive_mutex enet_mutex_g;
    5557
    5658  ClientConnection::ClientConnection(int port, const std::string& address) {
    5759    quit=false;
    5860    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;
    6164    established=false;
    6265  }
     
    6568    quit=false;
    6669    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;
    6973    established=false;
    7074  }
     
    8084    if(established)
    8185      closeConnection();
     86    delete serverAddress; // surely was created
    8287  }
    8388
     
    116121      return false;
    117122    }
    118     boost::recursive_mutex::scoped_lock lock(enet_mutex_);
     123    boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    119124    if(enet_peer_send(server, 0, packet)<0)
    120125      return false;
     
    126131    if(server==NULL)
    127132      return false;
    128     boost::recursive_mutex::scoped_lock lock(enet_mutex_);
     133    boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    129134    enet_host_flush(client);
    130135    lock.unlock();
     
    137142    ENetEvent *event;
    138143    {
    139       boost::recursive_mutex::scoped_lock lock(enet_mutex_);
     144      boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    140145      enet_initialize();
    141146      client = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, 0, 0);
     
    158163      //std::cout << "connection loop" << std::endl;
    159164      {
    160         boost::recursive_mutex::scoped_lock lock(enet_mutex_);
     165        boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    161166        if(enet_host_service(client, event, NETWORK_CLIENT_WAIT_TIME)<0){
    162167          // we should never reach this point
     
    192197    if(!disconnectConnection())
    193198      // if disconnecting failed destroy conn.
    194       boost::recursive_mutex::scoped_lock lock(enet_mutex_);
     199      boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    195200      enet_peer_reset(server);
    196201    return;
     
    199204  bool ClientConnection::disconnectConnection() {
    200205    ENetEvent event;
    201     boost::recursive_mutex::scoped_lock lock(enet_mutex_);
     206    boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    202207    enet_peer_disconnect(server, 0);
    203208    while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME) > 0){
     
    220225    ENetEvent event;
    221226    // 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);
    224229    if(server==NULL) {
    225230      COUT(2) << "ClientConnection: server == NULL" << std::endl;
  • code/trunk/src/network/ClientConnection.h

    r2756 r2773  
    4444
    4545#include <string>
    46 #ifndef WIN32_LEAN_AND_MEAN
    47 #  define WIN32_LEAN_AND_MEAN
    48 #endif
    49 #define NOMINMAX // required to stop windows.h screwing up std::min definition
    50 #include <enet/enet.h>
    51 #include <boost/thread/recursive_mutex.hpp>
    5246#include "PacketBuffer.h"
    5347
     
    8478    bool isConnected(){return established;}
    8579  private:
     80    ClientConnection(const ClientConnection& copy); // not used
    8681    bool processData(ENetEvent *event);
    8782    // implementation of the listener
     
    9388    // enet stuff
    9489    ENetHost *client;
    95     ENetAddress serverAddress;
     90    ENetAddress *serverAddress;
    9691    // quit-variable (communication with threads)
    9792    bool quit;
     
    10095    ENetPeer *server;
    10196    boost::thread *receiverThread_;
    102 
    103     static boost::recursive_mutex enet_mutex_;
    104   };
     97};
    10598
    10699
  • code/trunk/src/network/ClientInformation.cc

    r2662 r2773  
    4141#include "ClientInformation.h"
    4242
     43#include <enet/enet.h>
    4344#include <iostream> //debug
    4445
     
    162163  }
    163164
    164   enet_uint32 ClientInformation::getRTT(){
     165  uint32_t ClientInformation::getRTT(){
    165166    return this->peer_->roundTripTime;
    166167  }
  • code/trunk/src/network/ClientInformation.h

    r2756 r2773  
    4343#include "NetworkPrereqs.h"
    4444
    45 #ifndef WIN32_LEAN_AND_MEAN
    46 #  define WIN32_LEAN_AND_MEAN
    47 #endif
    48 #define NOMINMAX // required to stop windows.h screwing up std::min definition
    49 #include <enet/enet.h>
    50 #include <boost/thread/recursive_mutex.hpp>
    51 
    52 
    5345// WATCH OUT: THE CLIENTINFORMATION LIST IS NOT THREADSAFE ANYMORE
    5446
     
    8779    void addFailure();
    8880    void resetFailures();
    89     enet_uint32 getRTT();
     81    uint32_t getRTT();
    9082    double getPacketLoss();
    9183
  • code/trunk/src/network/ConnectionManager.cc

    r2759 r2773  
    4040#include "ConnectionManager.h"
    4141
     42#include <enet/enet.h>
    4243#include <iostream>
    43 #include <assert.h>
     44#include <cassert>
    4445// boost.thread library for multithreading support
    4546#include <boost/thread/thread.hpp>
    4647#include <boost/bind.hpp>
     48#include <boost/thread/recursive_mutex.hpp>
    4749
    4850#include "util/Math.h"
     
    6567{
    6668  //boost::thread_group network_threads;
     69  static boost::recursive_mutex enet_mutex_g;
    6770
    6871  ConnectionManager *ConnectionManager::instance_=0;
     
    7275    instance_=this;
    7376    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  }
    7881
    7982  ConnectionManager::ConnectionManager(int port){
     
    8184    instance_=this;
    8285    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;
    8589  }
    8690
     
    8993    instance_=this;
    9094    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;
    9398  }
    9499
     
    97102    instance_=this;
    98103    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;
    101107  }
    102108
     
    105111      quitListener();
    106112    instance_=0;
     113    delete bindAddress;
    107114  }
    108115
     
    132139
    133140  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);
    135142    if(enet_peer_send(peer, NETWORK_DEFAULT_CHANNEL, packet)!=0)
    136143      return false;
     
    150157    if(!instance_)
    151158      return false;
    152     boost::recursive_mutex::scoped_lock lock(ConnectionManager::enet_mutex);
     159    boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    153160    for(ClientInformation *i=ClientInformation::getBegin()->next(); i!=0; i=i->next()){
    154161      COUT(3) << "adding broadcast packet for client: " << i->getID() << std::endl;
     
    163170    if(server==NULL || !instance_)
    164171      return false;
    165     boost::recursive_mutex::scoped_lock lock(ConnectionManager::enet_mutex);
     172    boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    166173    enet_host_flush(server);
    167174    lock.unlock();
     
    174181    atexit(enet_deinitialize);
    175182    { //scope of the mutex
    176       boost::recursive_mutex::scoped_lock lock(ConnectionManager::enet_mutex);
     183      boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    177184      enet_initialize();
    178       server = enet_host_create(&bindAddress, NETWORK_MAX_CONNECTIONS, 0, 0);
     185      server = enet_host_create(bindAddress, NETWORK_MAX_CONNECTIONS, 0, 0);
    179186      lock.unlock();
    180187    }
     
    188195    while(!quit){
    189196      { //mutex scope
    190         boost::recursive_mutex::scoped_lock lock(ConnectionManager::enet_mutex);
     197        boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    191198        if(enet_host_service(server, event, NETWORK_WAIT_TIMEOUT)<0){
    192199          // we should never reach this point
     
    216223    // if we're finishied, destroy server
    217224    {
    218       boost::recursive_mutex::scoped_lock lock(ConnectionManager::enet_mutex);
     225      boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    219226      enet_host_destroy(server);
    220227      lock.unlock();
     
    230237    while(temp!=0){
    231238      {
    232         boost::recursive_mutex::scoped_lock lock(ConnectionManager::enet_mutex);
     239        boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    233240        enet_peer_disconnect(temp->getPeer(), 0);
    234241        lock.unlock();
     
    238245    //bugfix: might be the reason why server crashes when clients disconnects
    239246    temp = ClientInformation::getBegin()->next();
    240     boost::recursive_mutex::scoped_lock lock(ConnectionManager::enet_mutex);
     247    boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    241248    while( temp!=0 && enet_host_service(server, &event, NETWORK_WAIT_TIMEOUT) >= 0){
    242249      switch (event.type)
     
    267274
    268275
    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();
    275282  }
    276283
     
    294301  void ConnectionManager::disconnectClient(ClientInformation *client){
    295302    {
    296       boost::recursive_mutex::scoped_lock lock(ConnectionManager::enet_mutex);
     303      boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
    297304      enet_peer_disconnect(client->getPeer(), 0);
    298305      lock.unlock();
  • code/trunk/src/network/ConnectionManager.h

    r2759 r2773  
    4545#include <string>
    4646#include <map>
    47 // enet library for networking support
    48 #ifndef WIN32_LEAN_AND_MEAN
    49 #  define WIN32_LEAN_AND_MEAN
    50 #endif
    51 #define NOMINMAX // required to stop windows.h screwing up std::min definition
    52 #include <enet/enet.h>
    53 #include <boost/thread/recursive_mutex.hpp>
    5447
    5548#include "PacketBuffer.h"
     
    5750
    5851namespace boost { class thread; }
    59 
    60 namespace std
    61 {
    62   bool operator<(ENetAddress a, ENetAddress b);
    63 }
    6452
    6553namespace orxonox
     
    7866  class _NetworkExport ConnectionManager{
    7967    public:
    80     static boost::recursive_mutex enet_mutex;
    8168    ConnectionManager();
    8269    ConnectionManager(int port);
     
    9683
    9784  private:
     85    ConnectionManager(const ConnectionManager& copy); // not used
    9886    bool processData(ENetEvent *event);
    9987    void receiverThread();
    10088    void disconnectClients();
    101     int getClientID(ENetPeer peer);
    102     int getClientID(ENetAddress address);
     89    int getClientID(ENetPeer* peer);
     90    int getClientID(ENetAddress* address);
    10391    ENetPeer *getClientPeer(int clientID);
    10492    PacketBuffer buffer;
    10593
    10694    ENetHost *server;
    107     ENetAddress bindAddress;
     95    ENetAddress *bindAddress;
    10896
    10997    bool quit; // quit-variable (communication with threads)
  • code/trunk/src/network/GamestateHandler.cc

    r2171 r2773  
    1 #include <assert.h>
     1#include <cassert>
    22
    33#include "GamestateHandler.h"
  • code/trunk/src/network/Host.cc

    r2171 r2773  
    2727 */
    2828
    29 #include <assert.h>
     29#include <cassert>
    3030
    3131#include "Host.h"
  • code/trunk/src/network/NetworkPrereqs.h

    r2710 r2773  
    6969// Forward declarations
    7070//-----------------------------------------------------------------------
     71
     72// from ENet
     73struct _ENetPeer;
     74typedef _ENetPeer ENetPeer;
     75struct _ENetPacket;
     76typedef _ENetPacket ENetPacket;
     77struct _ENetEvent;
     78typedef _ENetEvent ENetEvent;
     79struct _ENetHost;
     80typedef _ENetHost ENetHost;
     81struct _ENetAddress;
     82typedef _ENetAddress ENetAddress;
     83
    7184namespace orxonox
    7285{
  • code/trunk/src/network/PacketBuffer.cc

    r2171 r2773  
    3333#include "PacketBuffer.h"
    3434
     35#include <enet/enet.h>
    3536#include <iostream>
    3637#include <queue>
     
    3839#include <boost/bind.hpp>
    3940#include <boost/thread/mutex.hpp>
     41#include <boost/thread/recursive_mutex.hpp>
    4042
    4143namespace orxonox
    4244{
    43    boost::recursive_mutex PacketBuffer::mutex_;
     45  static boost::recursive_mutex packetBuffer_mutex_g;
    4446
    4547  PacketBuffer::PacketBuffer() {
     
    5254
    5355  bool PacketBuffer::push(ENetEvent *ev) {
    54     boost::recursive_mutex::scoped_lock lock(mutex_);
     56    boost::recursive_mutex::scoped_lock lock(packetBuffer_mutex_g);
    5557    //std::cout << "event size inside packetbuffer " << ev->packet->dataLength << std::endl;
    5658    //   if(closed)
     
    8688 
    8789  ENetEvent *PacketBuffer::pop(){
    88     boost::recursive_mutex::scoped_lock lock(mutex_);
     90    boost::recursive_mutex::scoped_lock lock(packetBuffer_mutex_g);
    8991    //std::cout << "packetbuffer pop(address)" << std::endl;
    9092    if(first!=NULL /*&& !closed*/){
     
    106108
    107109  /*ENetPacket *PacketBuffer::pop(ENetAddress &address) {
    108     boost::recursive_mutex::scoped_lock lock(mutex_);
     110    boost::recursive_mutex::scoped_lock lock(packetBuffer_mutex_g);
    109111    //std::cout << "packetbuffer pop(address)" << std::endl;
    110112    if(first!=NULL ){
  • code/trunk/src/network/PacketBuffer.h

    r2756 r2773  
    4444#include "NetworkPrereqs.h"
    4545
    46 #ifndef WIN32_LEAN_AND_MEAN
    47 #  define WIN32_LEAN_AND_MEAN
    48 #endif
    49 #define NOMINMAX // required to stop windows.h screwing up std::min definition
    50 #include <enet/enet.h>
    51 #include <boost/thread/recursive_mutex.hpp>
    52 
    5346namespace orxonox
    5447{
     
    8275    QueueItem *last;
    8376    bool closed;
    84     static boost::recursive_mutex mutex_;
    8577  };
    8678
  • code/trunk/src/network/Server.cc

    r2662 r2773  
    4141#include "Server.h"
    4242
     43#include <enet/enet.h>
    4344#include <iostream>
    4445#include <cassert>
     
    5758#include "packet/Welcome.h"
    5859#include "packet/DeleteObjects.h"
    59 #include <util/Convert.h>
     60#include "util/Convert.h"
    6061#include "ChatListener.h"
    6162
  • code/trunk/src/network/packet/Chat.cc

    r2171 r2773  
    2828
    2929#include "Chat.h"
    30 #include <assert.h>
     30
     31#include <enet/enet.h>
     32#include <cassert>
    3133#include "network/Host.h"
    3234
  • code/trunk/src/network/packet/ClassID.cc

    r2759 r2773  
    3030
    3131#include "ClassID.h"
     32#include <enet/enet.h>
    3233#include "core/CoreIncludes.h"
    3334#include "core/Factory.h"
    3435#include <cstring>
    3536#include <string>
    36 #include <assert.h>
     37#include <cassert>
    3738#include <map>
    3839#include <queue>
  • code/trunk/src/network/packet/DeleteObjects.cc

    r2756 r2773  
    2929
    3030#include "DeleteObjects.h"
    31 #ifndef WIN32_LEAN_AND_MEAN
    32 #  define WIN32_LEAN_AND_MEAN
    33 #endif
    34 #define NOMINMAX // required to stop windows.h screwing up std::min definition
    3531#include <enet/enet.h>
    3632#include "network/synchronisable/Synchronisable.h"
    3733#include "core/CoreIncludes.h"
    38 #include <assert.h>
     34#include <cassert>
    3935
    4036namespace orxonox {
  • code/trunk/src/network/packet/Gamestate.cc

    r2759 r2773  
    2828
    2929#include "Gamestate.h"
     30#include <enet/enet.h>
     31#include <zlib.h>
     32#include <cassert>
    3033#include "../GamestateHandler.h"
    3134#include "../synchronisable/Synchronisable.h"
     
    3538#include "core/Iterator.h"
    3639
    37 #include <zlib.h>
    38 #include <cassert>
    3940
    4041
  • code/trunk/src/network/packet/Packet.cc

    r2756 r2773  
    3131
    3232#include <cassert>
    33 #ifndef WIN32_LEAN_AND_MEAN
    34 #  define WIN32_LEAN_AND_MEAN
    35 #endif
    36 #define NOMINMAX // required to stop windows.h screwing up std::min definition
    3733#include <enet/enet.h>
    3834#include <boost/bind.hpp>
     35#include <boost/thread/recursive_mutex.hpp>
    3936
    4037#include "network/ConnectionManager.h"
     
    5855
    5956std::map<size_t, Packet *> Packet::packetMap_;
    60 boost::recursive_mutex Packet::packetMap_mutex;
     57//! Static mutex for any packetMap_ access
     58static boost::recursive_mutex packetMap_mutex_g;
    6159
    6260Packet::Packet(){
     
    142140      // Assures we don't create a packet and destroy it right after in another thread
    143141      // 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);
    145143      packetMap_[(size_t)(void*)enetPacket_] = this;
    146144    }
     
    217215*/
    218216void Packet::deletePacket(ENetPacket *enetPacket){
    219   boost::recursive_mutex::scoped_lock lock(Packet::packetMap_mutex);
     217  boost::recursive_mutex::scoped_lock lock(packetMap_mutex_g);
    220218  // Get our Packet from a gloabal map with all Packets created in the send() method of Packet.
    221219  std::map<size_t, Packet*>::iterator it = packetMap_.find((size_t)enetPacket);
  • code/trunk/src/network/packet/Packet.h

    r2756 r2773  
    3232
    3333#include <map>
    34 #ifndef WIN32_LEAN_AND_MEAN
    35 #  define WIN32_LEAN_AND_MEAN
    36 #endif
    37 #define NOMINMAX // required to stop windows.h screwing up std::min definition
    38 #include <enet/enet.h>
    39 #include <boost/thread/recursive_mutex.hpp>
    4034
    4135namespace orxonox {
     
    7266    virtual unsigned int getSize() const =0;
    7367    virtual bool process()=0;
    74     enet_uint32 getFlags()
     68    uint32_t getFlags()
    7569      { return flags_; }
    7670    int getClientID()
     
    8478    Packet(uint8_t *data, unsigned int clientID);
    8579//    Packet(ENetPacket *packet, ENetPeer *peer);
    86     enet_uint32 flags_;
     80    uint32_t flags_;
    8781    unsigned int clientID_;
    8882    ENUM::Direction packetDirection_;
     
    9690  private:
    9791    static std::map<size_t, Packet *> packetMap_;
    98     //! Static mutex for any packetMap_ access
    99     static boost::recursive_mutex packetMap_mutex;
    10092    ENetPacket *enetPacket_;
    10193};
  • code/trunk/src/network/packet/Welcome.cc

    r2662 r2773  
    3131
    3232#include "Welcome.h"
     33#include <enet/enet.h>
     34#include <cassert>
    3335#include "network/Host.h"
    3436#include "network/synchronisable/Synchronisable.h"
    3537#include "core/CoreIncludes.h"
    36 #include <assert.h>
    3738
    3839namespace orxonox {
  • code/trunk/src/network/synchronisable/Synchronisable.cc

    r2759 r2773  
    3434#include <string>
    3535#include <iostream>
    36 #include <assert.h>
     36#include <cassert>
    3737
    3838#include "core/CoreIncludes.h"
  • code/trunk/src/network/synchronisable/Synchronisable.h

    r2759 r2773  
    3939#include "util/mbool.h"
    4040#include "core/OrxonoxClass.h"
    41 // TODO: this has to be removed
    42 // #include <OgreLight.h>
    43 // #include "OrxonoxPrereqs.h"
    44 // ============================
    4541#include "NetworkCallback.h"
    4642#include "SynchronisableVariable.h"
  • code/trunk/src/util/CMakeLists.txt

    r2710 r2773  
    4747  OutputHandler.cc
    4848  SignalHandler.cc
     49  Sleep.cc
    4950  String.cc
    5051  SubString.cc
  • code/trunk/src/util/Sleep.h

    r2710 r2773  
    3030 @file
    3131 @brief
    32     Functions for using sleep() and usleep() under windows.
     32    Functions for using sleep() and usleep() on windows.
    3333 */
    3434
     
    3838#include "UtilPrereqs.h"
    3939
    40 #ifdef ORXONOX_PLATFORM_WINDOWS
    41 #include <winbase.h>
    42 
    4340namespace orxonox
    4441{
    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);
    5945}
    6046
    61 #else /* Linux/Apple */
    62 
    63 #include <unistd.h>
    64 
    65 namespace orxonox
    66 {
    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 #endif
    82 
    8347#endif /* _Sleep_H__ */
Note: See TracChangeset for help on using the changeset viewer.