00001 #ifndef __GTHREAD_H
00002 #define __GTHREAD_H
00003
00005
00006
00007 #if defined BEOS
00008
00009 #define PRIORITY_IDLE B_LOW_PRIORITY
00010 #define PRIORITY_LOW B_LOW_PRIORITY
00011 #define PRIORITY_NORMAL B_NORMAL_PRIORITY
00012 #define PRIORITY_HIGH B_DISPLAY_PRIORITY
00013
00014 #elif defined WIN32
00015
00016 #define PRIORITY_IDLE THREAD_PRIORITY_IDLE
00017 #define PRIORITY_LOW THREAD_PRIORITY_BELOW_NORMAL
00018
00019 #else
00020
00021 #define PRIORITY_IDLE 1
00022 #define PRIORITY_LOW 2
00023
00024 #endif
00025
00026 enum GThreadState
00027 {
00028 LGITHREAD_INIT = 1,
00029 LGITHREAD_RUNNING = 2,
00030 LGITHREAD_ASLEEP = 3,
00031 LGITHREAD_EXITED = 4,
00032 LGITHREAD_ERROR = 5
00033 };
00034
00035 class LgiClass GThread
00036 {
00037 GThreadState State;
00038 int ReturnValue;
00039 OsThread hThread;
00040
00041 #if defined WIN32
00042 friend uint WINAPI ThreadEntryPoint(int i);
00043 uint ThreadId;
00044 #elif defined LINUX
00045 friend void *ThreadEntryPoint(void *i);
00046 #else
00047 friend int32 ThreadEntryPoint(void *i);
00048 #endif
00049
00050 protected:
00051 bool DeleteOnExit;
00052
00053 public:
00054 GThread();
00055 virtual ~GThread();
00056
00057
00058 OsThread Handle() { return hThread; }
00059 GThreadState GetState() { return State; }
00060 virtual int ExitCode();
00061 virtual bool IsExited();
00062
00063
00064 virtual void Run();
00065 virtual void Terminate();
00066 virtual int Priority();
00067 virtual void Priority(int p);
00068
00069
00070 virtual int Main();
00071
00072
00073 virtual void OnBeforeMain() {}
00074 virtual void OnAfterMain() {}
00075 };
00076
00077 #endif