a645502bd5886aaa02cfd61eca12876f6b9fdd34
[IRC.git] / Robust / src / Runtime / oooJava / hashStructure.h
1 #ifndef HASHSTRUCTURE_H_\r
2 #define HASHSTRUCTURE_H_\r
3 \r
4 #include "mlp_runtime.h"\r
5 //#include "WaitingQueue.h"\r
6 \r
7 #define ITEM_NOT_AT_FRONT_OF_WAITINGQ 3\r
8 #define TRAVERSER_FINISHED 2\r
9 #define bitvt unsigned long long\r
10 \r
11 //Note READEFFECT = READBIN and WRITEEFFECT=WRITEBIN. They mean the same thing\r
12 //but are named differently for clarity in code.\r
13 #define READEFFECT 0\r
14 #define WRITEEFFECT 1\r
15 #define WAITINGQUEUENOTE 2\r
16 \r
17 #define READBIN 0\r
18 #define WRITEBIN 1\r
19 #define BINMASK 1\r
20 #define PARENTBIN 1\r
21 \r
22 #define SPECNOTREADY 2\r
23 #define READY 1\r
24 #define NOTREADY 0\r
25 \r
26 #define TRUE 1\r
27 #define FALSE 0\r
28 \r
29 #define RNUMBINS 64\r
30 #define RNUMREAD 64\r
31 #define RNUMRENTRY 256\r
32 #define RH_MASK (RNUMBINS)-1\r
33 \r
34 //Note: put resolved things at the end and unresolved at the front.\r
35 typedef struct BinItem_rcr {\r
36   int total;\r
37   int status;\r
38   int type;\r
39   //TODO keep track of record ptr here\r
40   struct BinItem_rcr * next;\r
41 } BinItem_rcr;\r
42 \r
43 typedef struct BinElement_rcr {\r
44   BinItem_rcr * head;\r
45   BinItem_rcr * tail;\r
46 } BinElement_rcr;\r
47 \r
48 typedef struct Hashtable_rcr {\r
49   BinElement_rcr array[RNUMBINS];\r
50   //  WaitingQueueBin * waitingQueue;\r
51 } HashStructure;\r
52 \r
53 //Todo this is a clone of REntry, remove data fields as necessary\r
54 typedef struct Entry_rcr {\r
55   SESEcommon * task;\r
56   bitv bitindex;\r
57 } TraverserData;\r
58 \r
59 typedef struct WriteBinItem_rcr {\r
60   BinItem_rcr item;\r
61   SESEcommon * task;\r
62   bitv bitindexwr;\r
63   bitv bitindexrd;\r
64 } WriteBinItem_rcr;\r
65 \r
66 typedef struct ReadBinItem_rcr {\r
67   BinItem_rcr item;\r
68   TraverserData array[RNUMREAD];\r
69   //We don't need a head index since if the item before it was freed, then all these would be considered ready as well.\r
70   int index;\r
71 } ReadBinItem_rcr;\r
72 \r
73 extern HashStructure ** allHashStructures;\r
74 \r
75 void rcr_createMasterHashTableArray(int maxSize); //temporary\r
76 HashStructure* rcr_createHashtable(int sizeofWaitingQueue);\r
77 WriteBinItem_rcr* rcr_createWriteBinItem();\r
78 ReadBinItem_rcr* rcr_createReadBinItem();\r
79 int rcr_isReadBinItem(BinItem_rcr* b);\r
80 int rcr_isWriteBinItem(BinItem_rcr* b);\r
81 inline int rcr_generateKey(void * ptr);\r
82 \r
83 //Method signatures are not in their final form since I have still not decided what is the optimum amount of data\r
84 //to store in each entry.\r
85 \r
86 int rcr_WRITEBINCASE(HashStructure *T, void *ptr, SESEcommon *task, void *heaproot);\r
87 int rcr_READBINCASE(HashStructure *T, void *ptr, SESEcommon * task, void *heaproot);\r
88 int rcr_TAILREADCASE(HashStructure *T, void * ptr, BinItem_rcr *val, BinItem_rcr *bintail, int key, SESEcommon * task, void *heaproot);\r
89 void rcr_TAILWRITECASE(HashStructure *T, void *ptr, BinItem_rcr *val, BinItem_rcr *bintail, int key, SESEcommon * task, void *heaproot);\r
90 \r
91 #endif\r