00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef _SAMPLING_H_
00036 #define _SAMPLING_H_
00037
00038 #include "../main/includes.h"
00039 #include "../prof/lock.h"
00040
00048 class Sampling {
00049
00051 enum CMD {
00052
00053 CMD_TURN_ON,
00054 CMD_TURN_OFF,
00055 CMD_TERMINATE
00056 };
00057
00058 private:
00059
00061 CMD _cmd;
00062
00063 #ifdef USE_RAW_MONITORS
00064
00065 Lock _lock;
00066 #else
00067 #ifdef WIN32
00068
00069 HANDLE _turnedOn;
00070
00072 CRITICAL_SECTION _cs;
00073 #else
00074
00075 pthread_cond_t _cond;
00076
00078 pthread_mutex_t _mutex;
00079 #endif
00080 #endif
00081
00082 public:
00083
00089 Sampling( JVMPI_Interface* jvmpi);
00090
00092 ~Sampling();
00093
00103 int startThread(int turnedOn);
00104
00108 void terminateThread();
00109
00110 #ifndef USE_RAW_MONITORS
00111
00114 void turnOn();
00115
00119 void turnOff();
00120 #endif
00121
00122 private:
00123
00125 void main();
00126
00128 void doOneSample();
00129
00130 private:
00131
00136 static void samplingMain( void*);
00137
00138 #ifdef _DEBUG
00139 public:
00140
00141 unsigned long start;
00142 unsigned long finish;
00143 unsigned long samples;
00144 #endif // _DEBUG
00145
00146 private:
00147
00149 int _terminated;
00150
00151 public:
00152
00159 int isTerminated();
00160 };
00161
00162 #endif // _SAMPLING_H_