Update of /cvsroot/javaprofiler/library/src/delay
In directory usw-pr-cvs1:/tmp/cvs-serv1062/src/delay
Added Files:
Makefile Makefile.mak Makefile.rules delay.cpp delay.h
dir.info
Log Message:
shared memory implementation; java client and dynamic library can
now communicate thru sockets or shmem;
main README completely rewritten;
new classes - for shared memory, semaphores etc.;
java native class CommunShMem implementation
--- NEW FILE: Makefile ---
include ../../config.mk
include Makefile.rules
--- NEW FILE: Makefile.mak ---
!include ../../config.mk
!include Makefile.rules
--- NEW FILE: Makefile.rules ---
delay.o \
delay.obj: delay.cpp ../main/includes.h
$(CCC) $(CPPFLAGS) delay.cpp
--- NEW FILE: delay.cpp ---
#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
}
--- NEW FILE: delay.h ---
#ifndef _DELAY_H_
#define _DELAY_H_
/** Delay in milliseconds. This class should be used when
** sleeping for N milliseconds is necessary. Its implementation
** is system/platform dependend.
**
** @author Petr Luner, Marek Przeczek */
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.
**
** @param ms number of milliseconds */
void delay( long ms);
};
#endif // _DELAY_H_
--- NEW FILE: dir.info ---
FILES = delay
CLEAN_FILES = *.pdb *.obj *.o
|