Go to the documentation of this file.00001
00005 #ifndef THREAD_MANAGEMENT_H
00006 #define THREAD_MANAGEMENT_H
00007
00008
00009
00010 #ifdef _WIN32
00011
00012 #else
00013 #include <pthread.h>
00014 #endif
00015
00016 namespace skepu
00017 {
00018
00019 #ifdef _WIN32
00020
00021 #else
00022
00023 #define THREAD_FINISH pthread_exit(NULL);
00024
00035 class Threads
00036 {
00037
00038 public:
00039 typedef pthread_t ThreadID;
00040 typedef void ThreadFuncArg;
00041 typedef void *(*ThreadFunc)(void*);
00042
00050 void fork(ThreadFunc func, ThreadFuncArg* arg, ThreadID* thread)
00051 {
00052 int err;
00053 err = pthread_create(thread, NULL, func, arg);
00054 if(err) {std::cerr<<"ERROR creating threads\n";}
00055 }
00056
00062 void join(ThreadID thread)
00063 {
00064 pthread_join(thread, NULL);
00065 }
00066
00072 void cancel(ThreadID thread)
00073 {
00074 pthread_cancel(thread);
00075 }
00076
00077 };
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155 #endif
00156
00157
00158 }
00159
00160 #endif