diff src/parallel_execution/main.c @ 160:73c393f0dca3

fix main.c
author mir3636
date Fri, 18 Nov 2016 18:16:30 +0900
parents 63ab65b28466
children 06cfc1289361
line wrap: on
line diff
--- a/src/parallel_execution/main.c	Wed Nov 16 21:29:01 2016 +0900
+++ b/src/parallel_execution/main.c	Fri Nov 18 18:16:30 2016 +0900
@@ -87,7 +87,7 @@
     goto createData1(context, &context->data[D_Allocate]->allocate, &context->data[D_LoopCounter]->loopCounter);
 }
 
-__code createData2(struct Context* context, struct LoopCounter* loopCounter, struct Array* array, struct Node* node) {
+__code createData2(struct Context* context, struct LoopCounter* loopCounter, struct Array* array, struct Node* node, Tree* tree) {
     int i = loopCounter->i;
 
     array->index = i;
@@ -97,54 +97,21 @@
     node->key = i;
     node->value = (union Data*)array;
 
-    context->next = CreateTask1;
+    tree->next = CreateTask1;
+    tree->node = node;
 
-    goto meta(context, C_put);
+    goto meta(context, loopCounter->tree->put);
 }
 
 __code createData2_stub(struct Context* context) {
     goto createData2(context,
             &context->data[D_LoopCounter]->loopCounter,
             &context->data[context->dataNum]->array,
-            &context->data[D_Node]->node);
-}
-
-__code createTask1(struct Context* context, struct Allocate* allocate) {
-    allocate->size = sizeof(struct Task);
-    allocator(context);
-    goto meta(context, CreateTask2);
-}
-
-__code createTask1_stub(struct Context* context) {
-    goto createTask1(context, &context->data[D_Allocate]->allocate);
-}
-
-__code createTask2(struct Context* context, struct Allocate* allocate) {
-    allocate->size = sizeof(struct Queue);
-    allocator(context);
-    goto meta(context, CreateTask3);
+            &context->data[D_Node]->node,
+            Gearef(context, Tree));
 }
 
-__code createTask2_stub(struct Context* context) {
-    goto createTask2(context, &context->data[D_Allocate]->allocate);
-}
-
-__code createTask3(struct Context* context, struct Allocate* allocate) {
-    allocate->size = sizeof(struct Queue);
-    allocator(context);
-    goto meta(context, CreateTask4);
-}
-
-__code createTask3_stub(struct Context* context) {
-    goto createTask3(context, &context->data[D_Allocate]->allocate);
-}
-
-__code meta_createTask4(struct Context* context, struct Queue* activeQueue, enum Code next) {
-    context->data[D_Queue] = (union Data *)activeQueue;
-    goto (context->code[next])(context);
-}
-
-__code createTask4(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Queue* waitMe, struct Queue* waitI, struct Element* element, struct Queue* activeQueue) {
+__code createTask1(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Queue* waitMe, struct Queue* waitI, struct Element* element, struct Queue* activeQueue) {
     int i = loopCounter->i;
 
     waitMe->first = 0;
@@ -169,12 +136,15 @@
     goto meta(context, SpawnTask);
 }
 
-__code createTask4_stub(struct Context* context) {
-    goto createTask4(context,
+__code createTask1_stub(struct Context* context) {
+    Task* task = &ALLOCATE(context, Task)->Task;
+    Queue* waitMe = &ALLOCATE(context, Queue)->Queue;
+    Queue* waitI = &ALLOCATE(context, Queue)->Queue;
+    goto createTask1(context,
             &context->data[D_LoopCounter]->loopCounter,
-            &context->data[context->dataNum-2]->task,
-            &context->data[context->dataNum-1]->queue,
-            &context->data[context->dataNum]->queue,
+            task,
+            waitMe,
+            waitI,
             &context->data[D_Element]->element,
             &context->data[D_ActiveQueue]->queue);
 }