Mercurial > hg > Members > Moririn
annotate src/parallel_execution/TaskIterator.cbc @ 468:ac244346c85d
Change used interface syntax from #include to #interface
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 Dec 2017 18:10:56 +0900 |
parents | 8d7e5d48cad3 |
children |
rev | line source |
---|---|
456 | 1 #include "../context.h" |
468
ac244346c85d
Change used interface syntax from #include to #interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
462
diff
changeset
|
2 #interface "Iterator.h" |
456 | 3 #include <stdio.h> |
4 | |
5 createTaskIterator(struct Context, struct List list) { | |
6 struct Iterator* iterator = new Iterator(); | |
7 struct TaskIterator* taskIterator = new TaskIterator(); | |
8 iterator->itearot = (union Data*)taskIterator; | |
9 iterator->exec = C_execTaskIterator; | |
10 iterator->barrier = C_barrierTaskIterator; | |
11 taskIterator->taskList = list; | |
12 } | |
13 | |
14 __code execTaskIterator(struct taskIterator* iterator, struct TaskManager* taskManager, struct Context* task, __code next(...)) { | |
15 if (iterator->list->next == null) { | |
16 goto next(...); | |
17 } | |
18 iterator->list = list->next; | |
19 struct Context* task = (struct Context*)iterator->list->data; | |
20 struct TaskManager taskManager = task->taskManager; | |
21 taskManager->spawn(task, C_execTaskIterator); | |
22 } | |
23 | |
24 __code barrierTaskIterator(struct MultiDimIterator* iterator, struct Context* task, __code next(...), __code whenWait(...)) { | |
25 if (__sync_fetch_and_sub(&iterator->count, 1) == 1) { | |
26 goto next(...); | |
27 } | |
28 goto whenWait(...); | |
29 } |