__code spawnTaskManagerImpl(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...)) { if (task->idgCount == 0) { goto taskSend(); } goto next(...); } __code taskSend(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...)) { if (task->gpu) { goto taskSend1(); } else { goto taskSend2(); } } __code taskSend1(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...)) { int workerId = taskManager->sendGPUWorkerIndex; if(++taskManager->sendGPUWorkerIndex >= taskManager->cpu) { taskManager->sendGPUWorkerIndex = taskManager->gpu; } struct Queue* queue = taskManager->workers[workerId]->tasks; goto queue->put(task, next(...)); } __code taskSend2(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...)) { int workerId = taskManager->sendCPUWorkerIndex; if(++taskManager->sendCPUWorkerIndex >= taskManager->maxCPU) { taskManager->sendCPUWorkerIndex = taskManager->cpu; } struct Queue* queue = taskManager->workers[workerId]->tasks; goto queue->put(task, next(...)); }