SkePU  1.2
 All Classes Namespaces Files Functions Variables Enumerations Friends Macros Groups Pages
thread_pool.h
Go to the documentation of this file.
1 
5 #ifndef DEVICE_H_A
6 #define DEVICE_H_A
7 
8 
9 #include <pthread.h>
10 #include <semaphore.h>
11 #include "thread_management.h"
12 
13 
14 
15 #include <iostream>
16 #include <stdlib.h>
17 #include <vector>
18 #include <map>
19 
20 
21 
22 
23 namespace skepu
24 {
25 
26 typedef void *(*ThreadFunc)(void *);
27 
28 struct WorkerThread
29 {
30  ThreadFunc job_func;
31  void *job_arg; /* its argument */
32 
33  unsigned virtual executeThis()
34  {
35  job_func(job_arg);
36  return 0;
37  }
38 
39  WorkerThread(ThreadFunc job, void *arg): job_func(job), job_arg(arg)
40  {
41 
42  }
43 
44  ~WorkerThread()
45  {
46  job_func = NULL;
47  job_arg = NULL;
48  }
49 };
50 
56 {
57 public:
58 
59  static pthread_mutex_t mutexSync;
60  static pthread_mutex_t mutexWorkCompletion;
61 
62 public:
63 
64  ThreadPool()
65  {
66  ThreadPool(2);
67  }
68 
69  ThreadPool(int maxThreads)
70  {
71  }
72 
73 
74 
75  ~ThreadPool()
76  {
77  }
78 
79 
80  void finishAll(int maxPollMilliSecs)
81  {
82  }
83 
84 
85  void destroyPool(int maxPollMilliSecs)
86  {
87  }
88 
89 
90  bool assignWork(WorkerThread *workerThread)
91  {
92  return true;
93  }
94 
95  bool fetchWork(WorkerThread **workerArg)
96  {
97  return true;
98  }
99 
100  void *threadExecute(void *param)
101  {
102  return 0;
103  }
104 
105 
106  void initializeThreads()
107  {
108  }
109 
110 private:
111  int maxThreads;
112 
113  pthread_cond_t condCrit;
114  sem_t availableWork;
115  sem_t availableThreads;
116 
117  std::vector<WorkerThread *> workerQueue;
118 
119  int topIndex;
120  int bottomIndex;
121 
122  int incompleteWork;
123 
124 
125  int queueSize;
126 
127 };
128 
129 pthread_mutex_t ThreadPool::mutexSync = PTHREAD_MUTEX_INITIALIZER;
130 pthread_mutex_t ThreadPool::mutexWorkCompletion = PTHREAD_MUTEX_INITIALIZER;
131 
132 }
133 
134 
135 #endif
136 
137 
ThreadPool class manages all the ThreadPool related activities. This includes keeping track of idle t...
Definition: thread_pool.h:55
Contains classes that help with thread management. Currently only Pthreads. This was used earlier whe...