00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _SUPPORT_THREAD_H_
00014 #define _SUPPORT_THREAD_H_
00015
00021 #include <support/Atom.h>
00022 #include <support/Locker.h>
00023
00024 #if _SUPPORTS_NAMESPACE
00025 namespace palmos {
00026 namespace support {
00027 #endif
00028
00033
00034
00035
00037
00045 class SThread : public virtual SAtom
00046 {
00047 public:
00048
00049 SThread();
00050
00052
00055 virtual status_t Run(const char* name, int32_t priority, size_t stackSize);
00056
00058
00061 virtual void RequestExit();
00063 void WaitForExit();
00064
00065 protected:
00066 virtual ~SThread();
00067
00069
00081 virtual bool ThreadEntry() = 0;
00083 virtual status_t AboutToRun(SysHandle thread);
00084
00086 bool ExitRequested() const;
00087
00088 private:
00089 #if TARGET_HOST == TARGET_HOST_PALMOS
00090 static void top_entry(void* object);
00091 #else
00092 static int32_t top_entry(void* object);
00093 #endif
00094
00095 status_t m_status;
00096 SysHandle m_thread;
00097
00098 SLocker m_lock;
00099 #if 0 // FIXME: Linux
00100 SysConditionVariableType m_ended;
00101 #else
00102 void* m_ended;
00103 #endif
00104 bool m_ending : 1;
00105 };
00106
00109 #if _SUPPORTS_NAMESPACE
00110 } }
00111 #endif
00112
00113 #endif