Mercurial > hg > Gears > GearsAgda
view src/synchronizedQueue/synchronizedQueueContext.h @ 143:34a7a21edc36
recude stack get using traverse field
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 09 Nov 2016 22:33:16 +0900 |
parents | a870c84acd0e |
children |
line wrap: on
line source
/* Context definition for synchronized queue example */ #include <pthread.h> #define ALLOCATE_SIZE 1000 enum Code { Code1, Code2, Code3, Code4, Code5, Code6, Code7, Code8, Code9, Code10, Code11, Sender, Put, ContinuePut, Receiver, Get, ContinueGet, ThreadExit, Exit, }; enum UniqueData { Allocate, Queue, Counter, TimeOut, }; struct Context { int codeNum; __code (**code) (struct Context *); void* heapStart; void* heap; long dataSize; int dataNum; union Data* head; union Data** data; }; union Data { long count; long timeOut; struct Queue { struct Element* first; struct Element* last; int count; pthread_mutex_t mutex; pthread_cond_t cond; } queue; struct Element { int value; struct Element* next; } element; struct Allocate { long size; enum Code after_put; enum Code after_get; enum Code after_fail; } allocate; };