Update of /cvsroot/javaprofiler/library/src/delay
In directory usw-pr-cvs1:/tmp/cvs-serv21710/src/delay
Modified Files:
delay.cpp delay.h
Log Message:
no message
Index: delay.cpp
===================================================================
RCS file: /cvsroot/javaprofiler/library/src/delay/delay.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** delay.cpp 2001/08/23 23:57:31 1.1
--- delay.cpp 2001/08/26 00:11:32 1.2
***************
*** 1,53 ****
#include "../main/includes.h"
- Delay::Delay() {
-
- #ifdef WIN32
- _wait = CreateEvent( NULL, TRUE, FALSE, NULL);
- #else
- pthread_cond_init( &_waitCond, NULL);
- pthread_mutex_init( &_waitMutex, NULL);
-
- pthread_mutex_lock( &_waitMutex);
- #endif
- }
-
- Delay::~Delay() {
-
- #ifdef WIN32
- CloseHandle( _wait);
- #else
- pthread_mutex_unlock( &_waitMutex);
-
- pthread_cond_destroy( &_waitCond);
- pthread_mutex_destroy( &_waitMutex);
- #endif
- }
-
void Delay::delay( long ms) {
#ifdef WIN32
! WaitForSingleObject( _wait, ms);
#else
! struct timespec ts;
! struct timeval tv;
!
! long sec;
! long microSec;
!
! gettimeofday( &tv, NULL);
!
! sec = tv.tv_sec;
!
! sec += ms/1000;
! microSec = (ms%1000)*1000+tv.tv_usec;
!
! sec += microSec/1000000;
! microSec = microSec%1000000;
! ts.tv_sec = sec;
! ts.tv_nsec = microSec*1000;
! pthread_cond_timedwait( &_waitCond, &_waitMutex, &ts);
#endif
}
--- 1,15 ----
#include "../main/includes.h"
void Delay::delay( long ms) {
#ifdef WIN32
! Sleep( ms);
#else
! timeval tv;
! tv.tv_sec = ms/1000;
! tv.tv_usec = (ms%1000)*1000;
! select( 0, NULL, NULL, NULL, &tv);
#endif
}
Index: delay.h
===================================================================
RCS file: /cvsroot/javaprofiler/library/src/delay/delay.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** delay.h 2001/08/23 23:57:31 1.1
--- delay.h 2001/08/26 00:11:32 1.2
***************
*** 10,32 ****
class Delay {
- #ifdef WIN32
- /// handle to event used to wait on in delay() method
- HANDLE _wait;
- #else
- /// condition variable used to wait on in delay() method
- pthread_cond_t _waitCond;
-
- /// associated mutex
- pthread_mutex_t _waitMutex;
- #endif
-
public:
- /// Default constructor.
- Delay();
-
- /// Destructor.
- ~Delay();
-
/** Sleep. This method delays calling thread
** for 'ms' milliseconds.
--- 10,15 ----
***************
*** 34,38 ****
** @param ms number of milliseconds */
! void delay( long ms);
};
--- 17,21 ----
** @param ms number of milliseconds */
! static void delay( long ms);
};
|