1
|
1 __code spawnTaskManagerImpl(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...)) {
|
|
2 if (task->idgCount == 0) {
|
|
3 goto taskSend();
|
|
4 }
|
|
5 goto next(...);
|
|
6 }
|
|
7
|
|
8 __code taskSend(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...)) {
|
|
9 if (task->gpu) {
|
|
10 goto taskSend1();
|
|
11 } else {
|
|
12 goto taskSend2();
|
|
13 }
|
|
14 }
|
|
15
|
|
16 __code taskSend1(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...)) {
|
|
17 int workerId = taskManager->sendGPUWorkerIndex;
|
|
18 if(++taskManager->sendGPUWorkerIndex >= taskManager->cpu) {
|
|
19 taskManager->sendGPUWorkerIndex = taskManager->gpu;
|
|
20 }
|
|
21 struct Queue* queue = taskManager->workers[workerId]->tasks;
|
|
22 goto queue->put(task, next(...));
|
|
23 }
|
|
24
|
|
25 __code taskSend2(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...)) {
|
|
26 int workerId = taskManager->sendCPUWorkerIndex;
|
|
27 if(++taskManager->sendCPUWorkerIndex >= taskManager->maxCPU) {
|
|
28 taskManager->sendCPUWorkerIndex = taskManager->cpu;
|
|
29 }
|
|
30 struct Queue* queue = taskManager->workers[workerId]->tasks;
|
|
31 goto queue->put(task, next(...));
|
|
32 }
|