SkePU  1.2
 All Classes Namespaces Files Functions Variables Enumerations Friends Macros Groups Pages
thread_management.h
Go to the documentation of this file.
1 
6 #ifndef THREAD_MANAGEMENT_H
7 #define THREAD_MANAGEMENT_H
8 
9 //Currently only works with pthreads in UNIX
10 
11 #ifdef _WIN32
12 //Make win threads thing
13 #else
14 #include <pthread.h>
15 #endif
16 
17 namespace skepu
18 {
19 
20 #ifdef _WIN32
21 //Make win threads thing
22 #else
23 
24 #define THREAD_FINISH pthread_exit(NULL);
25 
36 class Threads
37 {
38 
39 public:
40  typedef pthread_t ThreadID;
41  typedef void ThreadFuncArg;
42  typedef void *(*ThreadFunc)(void*);
43 
51  void fork(ThreadFunc func, ThreadFuncArg* arg, ThreadID* thread)
52  {
53  int err;
54  err = pthread_create(thread, NULL, func, arg);
55  if(err)
56  {
57  std::cerr<<"ERROR creating threads\n";
58  }
59  }
60 
66  void join(ThreadID thread)
67  {
68  pthread_join(thread, NULL);
69  }
70 
76  void cancel(ThreadID thread)
77  {
78  pthread_cancel(thread);
79  }
80 
81 };
82 
83 
84 #endif
85 
86 
87 }
88 
89 #endif
90 
91 
void cancel(ThreadID thread)
Definition: thread_management.h:76
Definition: thread_management.h:36
void join(ThreadID thread)
Definition: thread_management.h:66
void fork(ThreadFunc func, ThreadFuncArg *arg, ThreadID *thread)
Definition: thread_management.h:51