Mercurial > hg > Members > Moririn
view src/synchronizedQueue/synchronizedQueueContext.h @ 66:a870c84acd0e
Change synchronizedQueue allocator from __code to Function call
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 15 Sep 2015 15:21:50 +0900 |
parents | 2a40d697bf4e |
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; };