Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 29, 2007, 6:13:47 PM (17 years ago)
Author:
landauf
Message:

changed retos usleep hack to a more generic solution:
#ifdef WIN32
#include <windows.h>
#define usleep(x) Sleep((x)/1000)

Location:
code/branches/FICN/src/network
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/network/ClientConnection.cc

    r352 r355  
    1212#include "ClientConnection.h"
    1313
    14 // workaround for usleep(int) under windows
    1514#ifdef WIN32
    16 #include "winbase.h"
     15#include <windows.h>
     16#define usleep(x) Sleep((x)/1000)
     17#else
     18#include <unistd.h>
    1719#endif
    1820
     
    3941  bool ClientConnection::waitEstablished(int milisec){
    4042    for(int i=0; i<=milisec && !established; i++)
    41 // under windows, use Sleep(milliseconds) instead of usleep(microseconds)
    42 #ifdef WIN32
    43       Sleep(1);
    44 #else
    4543      usleep(1000);
    46 #endif
     44
    4745    return established;
    4846  }
  • code/branches/FICN/src/network/PacketBufferTestExt.cc

    r351 r355  
    77
    88using namespace network;
    9 
    10 // workaround for usleep(int) under windows
    11 #ifdef WIN32
    12 #include "winbase.h"
    13 #endif
    149
    1510
     
    2722    test->push(&event);
    2823    if(i==5)
    29 // under windows, use Sleep(milliseconds) instead of usleep(microseconds)
    30 #ifdef WIN32
    31       Sleep(200);
    32 #else
    3324      usleep(200000);
    34 #endif
    3525  }
    3626  test->setClosed(true);
  • code/branches/FICN/src/network/dummyclient.cc

    r346 r355  
    88#include <enet/enet.h>
    99#include "PacketManager.h"
    10 
    11 // workaround for usleep(int) under windows
    12 #ifdef WIN32
    13 #include "winbase.h"
    14 #endif
    1510
    1611
     
    7368      cout << "failed sending" << endl;
    7469    }
    75 // under windows, use Sleep(milliseconds) instead of usleep(microseconds)
    76 #ifdef WIN32
    77     Sleep(1000);
    78 #else
    7970    usleep(1000000);
    80 #endif
    8171  }
    8272
  • code/branches/FICN/src/network/dummyserver.cc

    r352 r355  
    99#include "ConnectionManager.h"
    1010#include "PacketManager.h"
    11 
    12 // workaround for usleep(int) under windows
    13 #ifdef WIN32
    14 #include "winbase.h"
    15 #endif
    1611
    1712
     
    2823  while(!quit){
    2924    if(server.queueEmpty())
    30 // under windows, use Sleep(milliseconds) instead of usleep(microseconds)
    31 // Warning: Sleep(1) is ten times longer than usleep(100)!
    32 #ifdef WIN32
    33       Sleep(1);
    34 #else
     25// Warning: usleep(100) under windows is ten times longer than with unix!
    3526      usleep(100);
    36 #endif
    3727    else{
    3828      ENetAddress addr;
Note: See TracChangeset for help on using the changeset viewer.