1 #ifndef HASHSTRUCTURE_H_
\r
2 #define HASHSTRUCTURE_H_
\r
4 #include "mlp_runtime.h"
\r
5 #include "WaitingQueue.h"
\r
7 #define ITEM_NOT_AT_FRONT_OF_WAITINGQ 3
\r
8 #define TRAVERSER_FINISHED 2
\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
28 #define NUMRENTRY 256
\r
29 #define H_MASK (NUMBINS<<4)-1
\r
31 //Note: put resolved things at the end and unresolved at the front.
\r
32 typedef struct BinItem_rcr {
\r
36 //TODO keep track of record ptr here
\r
37 struct BinItem_rcr * next;
\r
40 typedef struct trackerElement {
\r
42 struct trackerElement * next;
\r
45 typedef struct tracker {
\r
46 TrackerElement * head;
\r
47 TrackerElement * tail;
\r
50 //TODO more closely tie this in with Jim's stuff
\r
51 struct genericObjectStruct {
\r
55 int ___cachedCode___;
\r
56 int ___cachedHash___;
\r
60 typedef struct BinElement_rcr {
\r
66 typedef struct Hashtable_rcr {
\r
67 BinElement_rcr array[NUMBINS];
\r
68 WaitingQueueBin * waitingQueue;
\r
71 //Todo this is a clone of REntry, remove data fields as necessary
\r
72 typedef struct entry_rcr{
\r
73 //fields to handle next item.
\r
74 struct Hashtable_rcr* hashtable;
\r
75 BinItem_rcr* binitem; //stores binItem so we can get access to the next ptr in the queue
\r
77 //fields to help resume traverser
\r
78 struct genericObjectStruct * resumePtr;
\r
79 // int allocsite; //not needed since we can get it form ptr later
\r
82 struct genericObjectStruct * heaproot;
\r
85 typedef struct WriteBinItem_rcr {
\r
90 typedef struct ReadBinItem_rcr {
\r
92 TraverserData array[NUMREAD];
\r
93 //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
98 typedef struct WQNote_rcr {
\r
101 } WaitingQueueNote;
\r
103 extern HashStructure ** allHashStructures;
\r
105 void rcr_createMasterHashTableArray(int maxSize); //temporary
\r
106 HashStructure* rcr_createHashtable(int sizeofWaitingQueue);
\r
107 WriteBinItem_rcr* rcr_createWriteBinItem();
\r
108 ReadBinItem_rcr* rcr_createReadBinItem();
\r
109 int rcr_isReadBinItem(BinItem_rcr* b);
\r
110 int rcr_isWriteBinItem(BinItem_rcr* b);
\r
111 inline int rcr_generateKey(void * ptr);
\r
113 //Method signatures are not in their final form since I have still not decided what is the optimum amount of data
\r
114 //to store in each entry.
\r
116 int rcr_WRITEBINCASE(HashStructure *T, void *ptr, int traverserID, SESEcommon *task, void *heaproot);
\r
117 int rcr_READBINCASE(HashStructure *T, void *ptr, int traverserID, SESEcommon * task, void *heaproot);
\r
118 int rcr_TAILREADCASE(HashStructure *T, void * ptr, BinItem_rcr *val, BinItem_rcr *bintail, int key, int traverserID, SESEcommon * task, void *heaproot);
\r
119 void rcr_TAILWRITECASE(HashStructure *T, void *ptr, BinItem_rcr *val, BinItem_rcr *bintail, int key, int traverserID, SESEcommon * task, void *heaproot);
\r
120 int rcr_REMOVETABLEITEM(HashStructure* table, void * ptr, int traverserID, SESEcommon *task, void * heaproot);
\r