Mercurial > hg > Gears > GearsAgda
view src/synchronizedQueue/synchronizedQueueContext.h @ 63:2a40d697bf4e
Delete while loop for cas
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 13 Jul 2015 23:20:31 +0900 |
parents | 4283b87ddbf4 |
children | a870c84acd0e |
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, Allocator, 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 next; enum Code after_put; enum Code after_get; enum Code after_fail; } allocate; };