00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __OpenSdkThreads_h__
00023 #define __OpenSdkThreads_h__
00024
00025 #include <pthread.h>
00026 #include <vector>
00027
00028 #define THREAD_POOL_SIZE 16
00029
00030 enum ThreadState { Idle, Running, Dead};
00031
00032 typedef void*(*FuncPointer)(void*);
00033
00034 class OpenSdkThread
00035 {
00036 public:
00037 static int runFunction(void * (func)(void*), void * arg);
00038 static void initThreadPool(void);
00039 static void cleanThreadPool(void);
00040
00041 OpenSdkThread();
00042 ~OpenSdkThread();
00043
00044 void deleteThread(void);
00045
00046 pthread_mutex_t runMutex;
00047 pthread_mutex_t stateMutex;
00048 ThreadState state;
00049 FuncPointer func;
00050 void * arg;
00051
00052 private:
00053 static std::vector<OpenSdkThread*>* threadVector;
00054
00055 };
00056
00057 #endif