Mercurial > hg > GearsTemplate
comparison src/parallel_execution/TaskManagerImpl.cbc @ 479:b8b412a7670a
Fix segmentation fault if multithread
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 28 Dec 2017 19:51:06 +0900 |
parents | a4d94c591246 |
children | 39b5df2d1c93 |
comparison
equal
deleted
inserted
replaced
478:0223c07c3946 | 479:b8b412a7670a |
---|---|
186 struct Queue* tasks = taskManager->workers[i]->tasks; | 186 struct Queue* tasks = taskManager->workers[i]->tasks; |
187 goto tasks->put(NULL, shutdownTaskManagerImpl1); | 187 goto tasks->put(NULL, shutdownTaskManagerImpl1); |
188 } | 188 } |
189 | 189 |
190 taskManager->loopCounter->i = 0; | 190 taskManager->loopCounter->i = 0; |
191 goto next(...); | 191 goto shutdownTaskManagerImpl2(); |
192 } | 192 } |
193 | 193 |
194 __code shutdownTaskManagerImpl1(struct TaskManagerImpl* taskManager) { | 194 __code shutdownTaskManagerImpl1(struct TaskManagerImpl* taskManager, __code next(...)) { |
195 int i = taskManager->loopCounter->i; | |
196 pthread_join(taskManager->workers[i]->thread, NULL); | |
197 taskManager->loopCounter->i++; | 195 taskManager->loopCounter->i++; |
198 goto shutdownTaskManagerImpl(); | 196 goto shutdownTaskManagerImpl(); |
199 } | 197 } |
198 | |
199 __code shutdownTaskManagerImpl2(struct TaskManagerImpl* taskManager, __code next(...)) { | |
200 int i = taskManager->loopCounter->i; | |
201 if (i < taskManager->numWorker) { | |
202 pthread_join(taskManager->workers[i]->thread, NULL); | |
203 taskManager->loopCounter->i++; | |
204 goto shutdownTaskManagerImpl2(); | |
205 } | |
206 taskManager->loopCounter->i = 0; | |
207 goto next(...); | |
208 } |