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 _THREAD_H_
00036 #define _THREAD_H_
00037
00038 #include "../main/includes.h"
00039 #include "../list/listItem.h"
00040 #include "../alloc/allocStatData.h"
00041 #include "../commun2/idObject.h"
00042 #include "../commun/binaryFormat.h"
00043 #include "../string/string.h"
00044 #include "../list/list.h"
00045 #include "../shared/thread.h"
00046 #include "../alloc/allocThreadObject.h"
00047 #include "../alloc/allocThreadMethod.h"
00048 #include "../cpu/cpuThreadMethod.h"
00049 #include "../mon/monThreadMethod.h"
00050 #include "../cpu/cpuStack.h"
00051 #include "../main/const.h"
00052 #include "../commun/buffer.h"
00053 #include "../allocator/allocator.h"
00054
00065 class Thread: public LI1,
00066 public LI2,
00067 public LI3,
00068 public LI4,
00069 public LI5,
00070 public AllocStatData,
00071 public IdObject,
00072 public InfoBinaryFormat {
00073 public:
00074
00076 String threadName;
00077
00079 GroupThread* group;
00080
00082 Thread* parent;
00083
00085 List<Thread,LI3> children;
00086
00088 jobjectID threadId;
00089
00091 JNIEnv* threadEnvId;
00092
00094 int active;
00095
00097 List<AllocThreadObject,LI1> allocThreadObjects;
00098
00100 List<AllocThreadMethod,LI1> allocThreadMethods;
00101
00103 List<CpuThreadMethod,LI2> cpuThreadMethods;
00104
00106 List<MonThreadMethod,LI2> monThreadMethods;
00107
00109 CpuStack stack;
00110
00114 JVMPI_CallTrace callTrace;
00115
00117 Thread* nextSuspended;
00118
00120 int hasRun;
00121
00127 int monitorEnter;
00128
00133 jobjectID monitorEnterObject;
00134
00139 unsigned long monitorEnterTime;
00140
00141 private:
00142
00143
00144 JVMPI_CallFrame _frames[MAX_TRACE];
00145
00146 public:
00147
00149 Thread() :
00150
00151 group( NULL),
00152 parent( NULL),
00153 threadId( 0),
00154 threadEnvId( NULL),
00155 active( 1),
00156 monitorEnter(0),
00157 monitorEnterObject(0),
00158 monitorEnterTime(0) {
00159
00160 callTrace.frames = _frames;
00161 }
00162
00164 virtual ~Thread() {}
00165
00174 JNIEnv* const& getKey(JNIEnv*& key) { return key = threadEnvId;}
00175
00185 int operator==(JNIEnv* const& key) { return (threadEnvId == key);}
00186
00193 static int hashKey(JNIEnv* const& key) { return (int)key;}
00194
00203 virtual Buffer& infoToBin( Buffer& b);
00204
00207 void deactivate();
00208
00209 #ifdef USE_ALLOCATOR
00210 private:
00211
00213 static Allocator _allocator;
00214
00215 public:
00216
00219 void* operator new( size_t sz) { return _allocator.get( sz);}
00220
00223 void operator delete( void* unit) { _allocator.put( unit);}
00224 #endif
00225
00226 public:
00227
00232 virtual eClassIdent getClassIdent() { return THREAD;}
00233
00240 virtual int isActive() { return active;}
00241
00247 virtual int isChanged() { return (activeChanged() || dataChanged());}
00248
00251 virtual void setUnchanged();
00252 };
00253
00254 #endif // _THREAD_H_