GearsOSの分散ファイルシステムの設計 |
Takahiro Ikki, Shinji Kono
琉球大学理工学研究科情報工学専攻
|
typedef struct Tree<>{
union Data* tree;
struct Node* node;
__code put(Impl* tree,Type* node, __code next(...));
__code get(Impl* tree, Type* node, __code next(...));
__code remove(Impl* tree,Type* node, __code next(...));
__code next(...);
} Tree;
struct Queue* queue = createSychronizedQueue(context);
struct Task* task = new Task();
goto queue->put(task, next(...));
typedef struct SynchronizedQueue <> impl Queue {
struct Element* top;
struct Element* last;
struct Atomic* atomic;
} SynchronizedQueue;
__code putSingleLinkedQueue(struct SingleLinkedQueue* queue, union Data* data, __code next(...)) {
Element* element = new Element();
element->data = data;
element->next = NULL;
queue->last->next = element;
queue->last = element;
goto next(...);
}
__code takeSingleLinkedQueue(struct SingleLinkedQueue* queue, __code next(union Data* data, ...)) {
printf("take\n");
struct Element* top = queue->top;
struct Element* nextElement = top->next;
if (queue->top == queue->last) {
data = NULL;
} else {
queue->top = nextElement;
data = nextElement->data;
}
goto next(data, ...);
}
__code sendDataRemoteDGMQueue(struct RemoteDGMQueue* cQueue, union Data* data, __code next(...), __code whenError(...)){
char recv_buf;
int send_size, recv_size;
send_size = send(cQueue->socket, data, sizeof(union Data), 0);
recv_size = recv(cQueue->socket, &recv_buf, 1, 0);
//error処理は省略
goto next(...);
}
__code getDataLocalDGMQueue(struct LocalDGMQueue* cQueue, __code next(...), __code whenError(...)){
int recv_size, send_size;
char send_buf;
union Data* recv_data;
recv_size = recv(cQueue->socket, recv_data, sizeof(union Data), 0);
//error処理は省略
Gearef(context, cQueue)->data = recv_data;
goto putLocalDGMQueue(recv_data, next);
}
__code Task2(TQueue* localDGMQueue){
goto localDGMQueue->take(Task3);
}
__code Task3(TQueue* localDGMQueue, FileString* string){
printf("take[%s] [num:%d]\n", string->str, string->size);
goto getData();
}
//プログラマが実装したいstub
__code Task3_stub(struct Context* context){
TQueue* localDGMQueue = (struct TQueue*)Gearef(context, TQueue)->tQueue;
FileString* string = Gearef(context, TQueue)->data;
goto Task3(context, localDGMQueue, string);
}
//自動生成されたErrorなstub
__code Task3_stub(struct Context* context) {
TQueue* localDGMQueue = Gearef(context, TQueue);
FileString* string = Gearef(context, FileString);
goto Task3(context, localDGMQueue, string);
}