00001 #ifndef THREAD_H_INCLUDED 00002 #define THREAD_H_INCLUDED 00003 00004 /********************************************************************* 00005 ** Thread 00006 *********************************************************************/ 00007 00008 typedef struct abyss_thread TThread; 00009 00010 void 00011 ThreadPoolInit(void); 00012 00013 typedef void TThreadProc(void * const userHandleP); 00014 typedef void TThreadDoneFn(void * const userHandleP); 00015 00016 void 00017 ThreadCreate(TThread ** const threadPP, 00018 void * const userHandle, 00019 TThreadProc * const func, 00020 TThreadDoneFn * const threadDone, 00021 abyss_bool const useSigchld, 00022 const char ** const errorP); 00023 00024 abyss_bool 00025 ThreadRun(TThread * const threadP); 00026 00027 abyss_bool 00028 ThreadStop(TThread * const threadP); 00029 00030 abyss_bool 00031 ThreadKill(TThread * threadP); 00032 00033 void 00034 ThreadWaitAndRelease(TThread * const threadP); 00035 00036 void 00037 ThreadExit(int const retValue); 00038 00039 void 00040 ThreadRelease(TThread * const threadP); 00041 00042 abyss_bool 00043 ThreadForks(void); 00044 00045 void 00046 ThreadUpdateStatus(TThread * const threadP); 00047 00048 #ifndef WIN32 00049 void 00050 ThreadHandleSigchld(pid_t const pid); 00051 #endif 00052 00053 /********************************************************************* 00054 ** Mutex 00055 *********************************************************************/ 00056 00057 #ifdef WIN32 00058 typedef HANDLE TMutex; 00059 #else 00060 #include <pthread.h> 00061 typedef pthread_mutex_t TMutex; 00062 #endif /* WIN32 */ 00063 00064 abyss_bool MutexCreate(TMutex *m); 00065 abyss_bool MutexLock(TMutex *m); 00066 abyss_bool MutexUnlock(TMutex *m); 00067 abyss_bool MutexTryLock(TMutex *m); 00068 void MutexFree(TMutex *m); 00069 00070 #endif
1.5.6