comparison src/synchronizedQueue/synchronizedQueue.c @ 66:a870c84acd0e

Change synchronizedQueue allocator from __code to Function call
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Tue, 15 Sep 2015 15:21:50 +0900
parents 2a40d697bf4e
children 5c3db1bef268
comparison
equal deleted inserted replaced
65:025fd6e90597 66:a870c84acd0e
12 #endif 12 #endif
13 13
14 #define NUM 100 14 #define NUM 100
15 15
16 extern __code initSynchronizedQueueContext(struct Context* context); 16 extern __code initSynchronizedQueueContext(struct Context* context);
17 extern void allocator(struct Context* context);
18
19 __code meta(struct Context* context, enum Code next) {
20 goto (context->code[next])(context);
21 }
17 22
18 //__code code1(struct Context* context) { 23 //__code code1(struct Context* context) {
19 // context->data[Allocate]->allocate.size = sizeof(struct Element); 24 // context->data[Allocate]->allocate.size = sizeof(struct Element);
20 // context->data[Allocate]->allocate.next = Code2; 25 // goto code2(context);
21 // goto meta(context, Allocator);
22 //}
23
24 __code meta(struct Context* context, enum Code next) {
25 goto (context->code[next])(context);
26 }
27
28 //__code code2(struct Context* context) {
29 // context->data[Allocate]->allocate.after_put = Code3;
30 // context->data[context->dataNum] -> element.value = 1024;
31 // goto meta(context, Sender);
32 //} 26 //}
33 27
34 __code code1(struct Context* context, struct Allocate* allocate) { 28 __code code1(struct Context* context, struct Allocate* allocate) {
35 allocate->size = sizeof(long); 29 allocate->size = sizeof(long);
36 allocate->next = Code2; 30 allocator(context);
37 goto meta(context, Allocator); 31 goto meta(context, Code2);
38 } 32 }
39 33
40 __code code1_stub(struct Context* context) { 34 __code code1_stub(struct Context* context) {
41 goto code1(context, &context->data[Allocate]->allocate); 35 goto code1(context, &context->data[Allocate]->allocate);
42 } 36 }
54 long loop = *count; 48 long loop = *count;
55 if(loop == NUM) { 49 if(loop == NUM) {
56 goto meta(context, ThreadExit); 50 goto meta(context, ThreadExit);
57 } 51 }
58 allocate->size = sizeof(struct Element); 52 allocate->size = sizeof(struct Element);
59 allocate->next = Code4; 53 allocator(context);
60 goto meta(context, Allocator); 54 goto meta(context, Code4);
61 } 55 }
62 56
63 __code code3_stub(struct Context* context) { 57 __code code3_stub(struct Context* context) {
64 goto code3(context, &context->data[Counter]->count, &context->data[Allocate]->allocate); 58 goto code3(context, &context->data[Counter]->count, &context->data[Allocate]->allocate);
65 } 59 }
113 goto put(context, &context->data[Allocate]->allocate, &context->data[Queue]->queue, &context->data[context->dataNum]->element); 107 goto put(context, &context->data[Allocate]->allocate, &context->data[Queue]->queue, &context->data[context->dataNum]->element);
114 } 108 }
115 109
116 __code code5(struct Context* context, struct Allocate* allocate) { 110 __code code5(struct Context* context, struct Allocate* allocate) {
117 allocate->size = sizeof(long); 111 allocate->size = sizeof(long);
118 allocate->next = Code6; 112 allocator(context);
119 goto meta(context, Allocator); 113 goto meta(context, Code6);
120 } 114 }
121 115
122 __code code5_stub(struct Context* context) { 116 __code code5_stub(struct Context* context) {
123 goto code5(context, &context->data[Allocate]->allocate); 117 goto code5(context, &context->data[Allocate]->allocate);
124 } 118 }