diff src/parallel_execution/worker.c @ 232:123b0d277b84

worker interface
author mir3636
date Sun, 22 Jan 2017 19:02:12 +0900
parents a1fb3f2d1a36
children 06133afb3b5b
line wrap: on
line diff
--- a/src/parallel_execution/worker.c	Sun Jan 22 18:19:23 2017 +0900
+++ b/src/parallel_execution/worker.c	Sun Jan 22 19:02:12 2017 +0900
@@ -3,17 +3,20 @@
 #include "context.h"
 #include "origin_cs.h"
 
-union Data* createWorker(struct Context* context, int id, Queue* queue) {
+union Data* createCPUWorker(struct Context* context, int id, Queue* queue, enum Code next) {
     struct Worker* worker = &ALLOCATE(context, Worker)->Worker;
-    worker->tasks = queue;
-    worker->id = id;
-    worker->runFlag = 1;
+    struct CPUWorker* cpuWorker = &ALLOCATE(context, CPUWorker)->CPUWorker;
+    worker->worker = (union Data*)cpuWorker;
+    cpuWorker->tasks = queue;
+    cpuWorker->id = id;
+    cpuWorker->runFlag = 1;
+    cpuWorker->next = next;
     worker->taskReceive = C_taskReceiveWorker;
     worker->shutdown = C_shutdownWorker;
     return (union Data*)(worker);
 }
 
-__code taskReceiveWorker(struct Context* context, Worker* worker) {
+__code taskReceiveWorker(struct Context* context, CPUWorker* worker) {
     if (! worker->runFlag)
         goto meta(context, worker->next);
     Queue* queue = worker->tasks;
@@ -22,7 +25,7 @@
 }
 
 __code taskReceiveWorker_stub(struct Context* context) {
-    Worker* worker = Gearef(context,Worker);
+    CPUWorker* worker = (CPUWorker *)GearImpl(context, Worker, worker);
     goto taskReceiveWorker(context,worker);
 }
 
@@ -33,7 +36,8 @@
 
 __code getTask1_stub(struct Context* context) {
     Worker* worker = Gearef(context,Worker);
-    Context* task = &worker->tasks->data->context; 
+    CPUWorker* cpuWorker = (CPUWorker *)GearImpl(context, Worker, worker);
+    Context* task = &cpuWorker->tasks->data->context; 
     goto getTask1(context,worker,task);
 }
 
@@ -45,11 +49,11 @@
 }
 #endif
 
-__code shutdownWorker(struct Context* context, Worker* worker) {
+__code shutdownWorker(struct Context* context, CPUWorker* worker) {
     worker->runFlag = 0;
 }
 
 __code shutdownWorker_stub(struct Context* context) {
-    Worker* worker = Gearef(context,Worker);
+    CPUWorker* worker = (CPUWorker *)GearImpl(context, Worker, worker);
     goto shutdownWorker(context,worker);
 }