annotate src/parallel_execution/queue.c @ 233:06133afb3b5b

create worker start_code
author mir3636
date Sun, 22 Jan 2017 20:02:21 +0900
parents c34e6aa10967
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
167
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
1 #include "queue.h"
131
a4507906938c Fix compile error but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
2 #include "origin_cs.h"
138
04a2f486a30d insert works but is not balanced
kono
parents: 136
diff changeset
3 #include <stdio.h>
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
167
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
5 union Data* createSingleLinkedQueue(struct Context* context) {
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
6 struct Queue* queue = &ALLOCATE(context, Queue)->Queue;
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
7 struct SingleLinkedQueue* singleLinkedQueue = &ALLOCATE(context, SingleLinkedQueue)->SingleLinkedQueue;
167
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
8 queue->queue = (union Data*)singleLinkedQueue;
169
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
9 singleLinkedQueue->top = NULL;
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
10 singleLinkedQueue->last = NULL;
167
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
11 queue->take = C_takeSingleLinkedQueue;
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
12 queue->put = C_putSingleLinkedQueue;
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
13 queue->isEmpty = C_isEmptySingleLinkedQueue;
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
14 queue->clear = C_clearSingleLinkedQueue;
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
15 return (union Data*)(queue);
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 }
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
167
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
18 void printQueue1(union Data* data) {
217
c34e6aa10967 Fix DataGear access name
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 203
diff changeset
19 struct Node* node = &data->Element.data->Node;
138
04a2f486a30d insert works but is not balanced
kono
parents: 136
diff changeset
20 if (node == NULL) {
04a2f486a30d insert works but is not balanced
kono
parents: 136
diff changeset
21 printf("NULL");
04a2f486a30d insert works but is not balanced
kono
parents: 136
diff changeset
22 } else {
04a2f486a30d insert works but is not balanced
kono
parents: 136
diff changeset
23 printf("key = %d ,", node->key);
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
24 printQueue1((union Data*)data->Element.next);
138
04a2f486a30d insert works but is not balanced
kono
parents: 136
diff changeset
25 }
04a2f486a30d insert works but is not balanced
kono
parents: 136
diff changeset
26 }
04a2f486a30d insert works but is not balanced
kono
parents: 136
diff changeset
27
167
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
28 void printQueue(union Data* data) {
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
29 printQueue1(data);
138
04a2f486a30d insert works but is not balanced
kono
parents: 136
diff changeset
30 printf("\n");
04a2f486a30d insert works but is not balanced
kono
parents: 136
diff changeset
31 }
04a2f486a30d insert works but is not balanced
kono
parents: 136
diff changeset
32
167
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
33 __code clearSingleLinkedQueue(struct Context* context, struct SingleLinkedQueue* queue,enum Code next) {
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
34 queue->top = NULL;
145
cc071cf1ba85 add stack clear interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 144
diff changeset
35 goto meta(context, next);
cc071cf1ba85 add stack clear interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 144
diff changeset
36 }
cc071cf1ba85 add stack clear interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 144
diff changeset
37
167
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
38 __code clearSingleLinkedQueue_stub(struct Context* context) {
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
39 goto clearSingleLinkedQueue(context, (struct SingleLinkedQueue *)context->data[D_Queue]->Queue.queue->Queue.queue, context->data[D_Queue]->Queue.next);
145
cc071cf1ba85 add stack clear interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 144
diff changeset
40 }
cc071cf1ba85 add stack clear interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 144
diff changeset
41
167
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
42 __code putSingleLinkedQueue(struct Context* context, struct SingleLinkedQueue* queue, struct Element* element, union Data* data, enum Code next) {
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
43 element->next = NULL;
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 113
diff changeset
44 element->data = data;
167
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
45 if (queue->last) {
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
46 Element* last = queue->last;
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
47 last->next = element;
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
48 queue->last = element;
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
49 } else {
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
50 queue->top = element;
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
51 queue->last = element;
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
52 }
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 113
diff changeset
53 goto meta(context, next);
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 }
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55
167
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
56 __code putSingleLinkedQueue_stub(struct Context* context) {
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
57 struct Element* element = &ALLOCATE(context, Element)->Element;
167
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
58 goto putSingleLinkedQueue(context,
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
59 (struct SingleLinkedQueue *)context->data[D_Queue]->Queue.queue->Queue.queue,
131
a4507906938c Fix compile error but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
60 element,
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
61 context->data[D_Queue]->Queue.data,
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
62 context->data[D_Queue]->Queue.next);
131
a4507906938c Fix compile error but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
63 }
a4507906938c Fix compile error but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 130
diff changeset
64
167
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
65 __code takeSingleLinkedQueue(struct Context* context, struct SingleLinkedQueue* queue, union Data** data, enum Code next) {
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
66 if (queue->top) {
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
67 *data = queue->top->data;
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
68 queue->top = queue->top->next;
136
a747dc9d4da6 stack refactering no compile error
mir3636
parents: 135
diff changeset
69 } else {
a747dc9d4da6 stack refactering no compile error
mir3636
parents: 135
diff changeset
70 *data = NULL;
a747dc9d4da6 stack refactering no compile error
mir3636
parents: 135
diff changeset
71 }
130
2bb5e4f0fd35 Stackinterface
ikkun
parents: 113
diff changeset
72 goto meta(context, next);
86
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 }
e06e1a9e569e create worker
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74
167
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
75 __code takeSingleLinkedQueue_stub(struct Context* context) {
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
76 goto takeSingleLinkedQueue(context,
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
77 (struct SingleLinkedQueue *)context->data[D_Queue]->Queue.queue->Queue.queue,
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
78 &context->data[D_Queue]->Queue.data,
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
79 context->data[D_Queue]->Queue.next);
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
80 }
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
81
167
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
82 __code isEmptySingleLinkedQueue(struct Context* context, struct SingleLinkedQueue* queue, enum Code next,enum Code whenEmpty) {
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
83 if (queue->top)
133
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
84 goto meta(context, next);
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
85 else
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
86 goto meta(context, whenEmpty);
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
87 }
568730b1239e call stack interface in rb_tree
mir3636
parents: 132
diff changeset
88
167
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
89 __code isEmptySingleLinkedQueue_stub(struct Context* context) {
34562e63981f create queue.c
mir3636
parents: 148
diff changeset
90 goto isEmptySingleLinkedQueue(context,
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
91 (struct SingleLinkedQueue *)context->data[D_Queue]->Queue.queue->Queue.queue,
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
92 context->data[D_Queue]->Queue.next,
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
93 context->data[D_Queue]->Queue.whenEmpty);
132
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
94 }
7c309e1aea73 Code Gears stack api
one
parents: 131
diff changeset
95
168
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
96 union Data* createSynchronizedQueue(struct Context* context) {
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
97 struct Queue* queue = &ALLOCATE(context, Queue)->Queue;
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
98 struct SingleLinkedQueue* singleLinkedQueue = &ALLOCATE(context, SingleLinkedQueue)->SingleLinkedQueue;
168
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
99 queue->queue = (union Data*)singleLinkedQueue;
169
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
100 singleLinkedQueue->top = NULL;
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
101 singleLinkedQueue->last = NULL;
168
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
102 queue->take = C_takeSynchronizedQueue;
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
103 queue->put = C_putSynchronizedQueue;
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
104 queue->isEmpty = C_isEmptySynchronizedQueue;
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
105 queue->clear = C_clearSynchronizedQueue;
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
106 return (union Data*)(queue);
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
107 }
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
108
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
109 __code clearSynchronizedQueue(struct Context* context, struct SingleLinkedQueue* queue,enum Code next) {
168
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
110 struct Element* top = queue->top;
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
111 if (__sync_bool_compare_and_swap(&queue->top, top, NULL)) {
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
112 goto meta(context, next);
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
113 } else {
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
114 goto meta(context, C_clearSynchronizedQueue);
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
115 }
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
116 }
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
117
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
118 __code clearSynchronizedQueue_stub(struct Context* context) {
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
119 goto clearSingleLinkedQueue(context, (struct SingleLinkedQueue *)context->data[D_Queue]->Queue.queue->Queue.queue, context->data[D_Queue]->Queue.next);
168
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
120 }
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
121
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
122 __code putSynchronizedQueue(struct Context* context, struct SingleLinkedQueue* queue, struct Element* element, union Data* data, enum Code next) {
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
123 element->next = NULL;
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
124 element->data = data;
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
125 if (queue->last) {
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
126 Element* last = queue->last;
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
127 if (__sync_bool_compare_and_swap(&queue->last, last, element)) {
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
128 last->next = element;
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
129 } else {
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
130 goto meta(context, C_putSynchronizedQueue);
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
131 }
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
132 } else {
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
133 if (__sync_bool_compare_and_swap(&queue->top, NULL, element)) {
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
134 queue->last = element;
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
135 } else {
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
136 goto meta(context, C_putSynchronizedQueue);
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
137 }
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
138 }
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
139 goto meta(context, next);
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
140 }
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
141
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
142 __code putSynchronizedQueue_stub(struct Context* context) {
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
143 struct Element* element = &ALLOCATE(context, Element)->Element;
168
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
144 goto putSynchronizedQueue(context,
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
145 (struct SingleLinkedQueue *)context->data[D_Queue]->Queue.queue->Queue.queue,
168
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
146 element,
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
147 context->data[D_Queue]->Queue.data,
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
148 context->data[D_Queue]->Queue.next);
168
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
149 }
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
150
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
151 __code takeSynchronizedQueue(struct Context* context, struct SingleLinkedQueue* queue, union Data** data, enum Code next) {
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
152 if (queue->top) {
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
153 struct Element* top = queue->top;
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
154 if (__sync_bool_compare_and_swap(&queue->top, top, top->next)) {
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
155 *data = top->data;
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
156 } else {
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
157 goto meta(context, C_takeSynchronizedQueue);
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
158 }
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
159 } else {
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
160 *data = NULL;
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
161 }
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
162 goto meta(context, next);
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
163 }
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
164
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
165 __code takeSynchronizedQueue_stub(struct Context* context) {
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
166 goto takeSynchronizedQueue(context,
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
167 (struct SingleLinkedQueue *)context->data[D_Queue]->Queue.queue->Queue.queue,
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
168 &context->data[D_Queue]->Queue.data,
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
169 context->data[D_Queue]->Queue.next);
168
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
170 }
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
171
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
172 __code isEmptySynchronizedQueue(struct Context* context, struct SingleLinkedQueue* queue, enum Code next,enum Code whenEmpty) {
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
173 if (queue->top)
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
174 goto meta(context, next);
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
175 else
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
176 goto meta(context, whenEmpty);
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
177 }
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
178
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
179 __code isEmptySynchronizedQueue_stub(struct Context* context) {
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
180 goto isEmptySynchronizedQueue(context,
203
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
181 (struct SingleLinkedQueue *)context->data[D_Queue]->Queue.queue->Queue.queue,
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
182 context->data[D_Queue]->Queue.next,
25db17f32ac2 replace Stack for stack
ikkun
parents: 182
diff changeset
183 context->data[D_Queue]->Queue.whenEmpty);
168
fa7419e2c67c Add synchornizedQueue
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 167
diff changeset
184 }