00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __THREAD_H__
00012 #define __THREAD_H__
00013 #include "RNPlatform/Inc/DLLExportAPI.h"
00014
00015 #if defined(linux) || defined(unix)
00016 #include <pthread.h>
00017 #endif
00018
00019 namespace RNReplicaNet
00020 {
00021
00022 class ThreadClass;
00023 const int kReplicaNetPreferredProcessorOSChoice = -1;
00028 class REPNETEXPORTAPI Thread
00029 {
00030 public:
00034 Thread();
00035
00039 virtual ~Thread();
00040
00046 void Begin(ThreadClass *threaded_class);
00047
00051 void Terminate(void);
00052
00056 bool GetTerminated(void);
00057
00062 static int CallThreadEntry(ThreadClass *thread_class);
00063
00068 bool GetIsRunning(void) const;
00069
00074 void SetPreferredProcessor(int processor = kReplicaNetPreferredProcessorOSChoice);
00075
00079 int GetPreferredProcessor(void);
00080
00081 private:
00082 friend class ThreadClass;
00083 ThreadClass *mThreadClass;
00084 #if defined(_WIN32)
00085 void *mThreadHandle;
00086
00087 #endif
00088 #if defined(linux) || defined(unix)
00089 pthread_t mThreadHandle;
00090 #endif
00091 #if defined (_PS2)
00092 int mThreadHandle;
00093 #endif
00094
00095 int mProcessor;
00096
00097 volatile bool mIsRunning;
00098 volatile bool mTerminateCalled;
00099 };
00100
00101 }
00102
00103 #endif