00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef UTD_THREADS_H_
00011 #define UTD_THREADS_H_
00012
00013
00014 #ifdef _WIN32
00015
00016 #include <windows.h>
00017 typedef HANDLE utd_thread;
00018 typedef unsigned (WINAPI *utd_thread_routine)(void *);
00019 typedef CRITICAL_SECTION utd_critical_section;
00020
00021 #define ENTERCRITICALSECTION(crit_section) EnterCriticalSection(&(crit_section));
00022 #define LEAVECRITICALSECTION(crit_section) LeaveCriticalSection(&(crit_section));
00023
00024 #else
00025
00026
00027 #include <pthread.h>
00028 typedef pthread_t utd_thread;
00029 typedef void *(*utd_thread_routine)(void *);
00030 typedef pthread_mutex_t utd_critical_section;
00031
00032 #define ENTERCRITICALSECTION(crit_section) pthread_mutex_lock (&(crit_section));
00033 #define LEAVECRITICALSECTION(crit_section) pthread_mutex_unlock(&(crit_section));
00034
00035 #endif
00036
00037
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041
00042 extern int utd_internal_error;
00043
00044
00045 extern utd_thread utd_start_thread(utd_thread_routine, void *data);
00046
00047
00048 extern void utd_end_thread(utd_thread thread);
00049
00050
00051 extern void utd_destroy_thread(utd_thread thread);
00052
00053
00054 extern void utd_wait_for_threads(const utd_thread *threads, int num);
00055
00056 #ifdef __cplusplus
00057 }
00058 #endif
00059
00060
00061 #endif