diff src/parallel_execution/examples/boundedBuffer/BoundedBuffer.cbc @ 493:82f0c49750f1

Add codeGear for boundedBuffer example
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Sun, 31 Dec 2017 01:36:18 +0900
parents 9333486471b9
children d8b2036c6942
line wrap: on
line diff
--- a/src/parallel_execution/examples/boundedBuffer/BoundedBuffer.cbc	Sat Dec 30 22:03:33 2017 +0900
+++ b/src/parallel_execution/examples/boundedBuffer/BoundedBuffer.cbc	Sun Dec 31 01:36:18 2017 +0900
@@ -1,6 +1,6 @@
-#include "../../context.h"
-#interface Queue.h
-#interface Semaphore.h
+#include "../../../context.h"
+#interface "Queue.h"
+#interface "Semaphore.h"
 
 Queue* createBoundedBuffer(struct Context* context, int size) {
     struct Queue* queue = new Queue();
@@ -14,63 +14,63 @@
     queue->queue = (union Data*)boundedBuffer;
     queue->take = C_takeBoundedBuffer;
     queue->put = C_putBoundedBuffer;
-    queue->isEmpty = C_isEmptyBoundedBuffer;
-    queue->clear = C_clearBoundedBuffer;
+    // queue->isEmpty = C_isEmptyBoundedBuffer;
+    // queue->clear = C_clearBoundedBuffer;
     return queue;
 }
 
-__code putBoudnedBuffer(struct BoundedBuffer* boundedBuffer, union Data* data, __code next(union Data* data, ...)) {
-    struct Semaphore sem = boundedBuffer->emptyCount;
-    goto sem->p(putBoudnedBuffer1);
+__code putBoundedBuffer(struct BoundedBuffer* queue, union Data* data, __code next(...)) {
+    struct Semaphore* sem = queue->emptyCount;
+    goto sem->p(putBoundedBuffer1);
 }
 
-__code putBoudnedBuffer1(struct BoundedBuffer* boundedBuffer, union Data* data, __code next(union Data* data, ...)) {
-    struct Semaphore sem = boundedBuffer->lock;
-    goto sem->p(putBoudnedBuffer2);
+__code putBoundedBuffer1(struct BoundedBuffer* queue, union Data* data, __code next(...)) {
+    struct Semaphore* sem = queue->lock;
+    goto sem->p(putBoundedBuffer2);
 }
 
-__code putBoudnedBuffer2(struct BoundedBuffer* boundedBuffer, union Data* data, __code next(union Data* data, ...)) {
+__code putBoundedBuffer2(struct BoundedBuffer* queue, union Data* data, __code next(...)) {
     struct Element* element = new Element();
     element->data = data;
     element->next = NULL;
     struct Element* last = queue->last;
     last->next = element;
-    struct Semaphore sem = boundedBuffer->lock;
-    goto sem->v(putBoudnedBuffer3);
+    struct Semaphore* sem = queue->lock;
+    goto sem->v(putBoundedBuffer3);
 }
 
-__code putBoudnedBuffer3(struct BoundedBuffer* boundedBuffer, union Data* data, __code next(union Data* data, ...)) {
-    struct Semaphore sem = boundedBuffer->fullCount;
-    goto sem->v(putBoudnedBuffer4);
+__code putBoundedBuffer3(struct BoundedBuffer* queue, union Data* data, __code next(...)) {
+    struct Semaphore* sem = queue->fullCount;
+    goto sem->v(putBoundedBuffer4);
 }
 
-__code putBoudnedBuffer4(struct BoundedBuffer* boundedBuffer, union Data* data, __code next(union Data* data, ...)) {
+__code putBoundedBuffer4(struct BoundedBuffer* queue, union Data* data, __code next(...)) {
     goto next(data, ...);
 }
-__code takeBoudnedBuffer(struct BoundedBuffer* boundedBuffer, __code next(union Data* data, ...)) {
-    struct Semaphore sem = boundedBuffer->fullCount;
-    goto sem->p(takeBoudnedBuffer1);
+__code takeBoundedBuffer(struct BoundedBuffer* queue, __code next(union Data* data, ...)) {
+    struct Semaphore* sem = queue->fullCount;
+    goto sem->p(takeBoundedBuffer1);
 }
 
-__code takeBoudnedBuffer1(struct BoundedBuffer* boundedBuffer, __code next(union Data* data, ...)) {
-    struct Semaphore sem = boundedBuffer->lock;
-    goto sem->p(takeBoudnedBuffer2);
+__code takeBoundedBuffer1(struct BoundedBuffer* queue, __code next(union Data* data, ...)) {
+    struct Semaphore* sem = queue->lock;
+    goto sem->p(takeBoundedBuffer2);
 }
 
-__code takeBoudnedBuffer2(struct BoundedBuffer* boundedBuffer, __code next(union Data* data, ...)) {
+__code takeBoundedBuffer2(struct BoundedBuffer* queue, __code next(union Data* data, ...)) {
     struct Element* top = queue->top;
     struct Element* nextElement = top->next;
     data = nextElement->data;
     queue->top = nextElement;
-    struct Semaphore sem = boundedBuffer->lock;
-    goto sem->v(takeBoudnedBuffer3);
+    struct  Semaphore* sem = queue->lock;
+    goto sem->v(takeBoundedBuffer3);
 }
 
-__code takeBoudnedBuffer3(struct BoundedBuffer* boundedBuffer, __code next(union Data* data, ...)) {
-    struct Semaphore sem = boundedBuffer->emptyCount;
-    goto sem->v(takeBoudnedBuffer4);
+__code takeBoundedBuffer3(struct BoundedBuffer* queue, __code next(union Data* data, ...)) {
+    struct Semaphore* sem = queue->emptyCount;
+    goto sem->v(takeBoundedBuffer4);
 }
 
-__code takeBoudnedBuffer4(struct BoundedBuffer* boundedBuffer, __code next(union Data* data, ...)) {
+__code takeBoundedBuffer4(struct BoundedBuffer* queue, __code next(union Data* data, ...)) {
     goto next(data, ...);
 }