00001
00002 Copyright (c) 2001, Lee Patterson & Ant Works Software
00003 http://ssobjects.sourceforge.net
00004
00005 Original source from Win32 Multithreaded Programming
00006 Copyright (c) 1997 by Aaron Michael Cohen and Mike Woodring
00007
00008 filename : mclcritsec.cpp
00009 author : Lee Patterson (lee@antws.com)
00010 *********************************************************************/
00011
00012 #ifndef MCLTHREAD_H
00013 #define MCLTHREAD_H
00014
00015 #include "msdefs.h"
00016
00017 #include <pthread.h>
00018
00019 namespace ssobjects
00020 {
00021
00022 typedef void* threadReturn;
00023
00024
00025
00026 class CMclThread;
00027
00028
00029
00030
00031
00032
00033
00034 class CMclThreadHandler
00035 {
00036 public:
00037
00038
00039 virtual ~CMclThreadHandler();
00040
00041
00042
00043
00044
00045
00046
00047 virtual threadReturn ThreadHandlerProc(void) = 0;
00048 };
00049
00050 class CMclThread
00051 {
00052 protected:
00053 CMclThreadHandler *m_pcThreadHandler;
00054 pthread_t m_Thread;
00055 DWORD m_dwStatus;
00056
00057 public:
00058
00059
00060
00061 CMclThread( CMclThreadHandler *pcThreadHandler);
00062
00063 void Wait(DWORD dwMilliSeconds=INFINITE);
00064
00065
00066 pthread_t GetThread() {return m_Thread;}
00067
00068
00069 DWORD Suspend(void);
00070
00071
00072 DWORD Resume(void);
00073
00074
00075 BOOL Terminate( DWORD dwExitCode);
00076
00077
00078 BOOL GetExitCode( DWORD *pdwExitCode);
00079
00080
00081 BOOL SetPriority( int nPriority);
00082
00083
00084 int GetPriority(void);
00085
00086
00087 DWORD GetThreadId(void);
00088
00089 private:
00090
00091 static void* CallThreadHandlerProc(void *pThreadHandler);
00092 CMclThread(const CMclThread&);
00093 CMclThread& operator=(const CMclThread&);
00094 };
00095
00096 };
00097
00098 #endif //MCLTHREAD_H