newTable->array[i].head=NULL;
newTable->array[i].tail=NULL;
}
-
+ newTable->memPoolRead = poolcreate( sizeof(ReadBinItem_rcr), NULL );
+ newTable->memPoolWrite = poolcreate( sizeof(WriteBinItem_rcr), NULL );
return newTable;
}
-WriteBinItem_rcr* rcr_createWriteBinItem(){
- WriteBinItem_rcr* binitem=(WriteBinItem_rcr*)RUNMALLOC(sizeof(WriteBinItem_rcr));
+WriteBinItem_rcr* rcr_createWriteBinItem( HashStructure* htable ){
+ WriteBinItem_rcr* binitem=(WriteBinItem_rcr*)poolalloc( htable->memPoolWrite );
binitem->item.type=WRITEBIN;
+ binitem->item.next=NULL;
return binitem;
}
-ReadBinItem_rcr* rcr_createReadBinItem(){
- ReadBinItem_rcr* binitem=(ReadBinItem_rcr*)RUNMALLOC(sizeof(ReadBinItem_rcr));
+ReadBinItem_rcr* rcr_createReadBinItem( HashStructure* htable ){
+ ReadBinItem_rcr* binitem=(ReadBinItem_rcr*)poolalloc( htable->memPoolRead );
binitem->index=0;
binitem->item.type=READBIN;
+ binitem->item.next=NULL;
return binitem;
}
} while(val==(BinItem_rcr*)0x1);
if (val==NULL) {
- BinItem_rcr * b=(BinItem_rcr*)rcr_createWriteBinItem();
+ BinItem_rcr * b=(BinItem_rcr*)rcr_createWriteBinItem( T );
WriteBinItem_rcr * td = (WriteBinItem_rcr*)b;
b->total=1;
b->status=READY;
}
}
- WriteBinItem_rcr *b=rcr_createWriteBinItem();
+ WriteBinItem_rcr *b=rcr_createWriteBinItem( T );
b->item.total=1;
b->task=task;
} while(val==(BinItem_rcr*)0x1);
if (val==NULL) {
- BinItem_rcr * b=(BinItem_rcr*)rcr_createReadBinItem();
+ BinItem_rcr * b=(BinItem_rcr*)rcr_createReadBinItem( T );
ReadBinItem_rcr* readbin=(ReadBinItem_rcr*)b;
TraverserData * td = &(readbin->array[readbin->index++]);
b->total=1;
}
if (readbintail->index==RNUMREAD) { // create new read group
- ReadBinItem_rcr* rb=rcr_createReadBinItem();
+ ReadBinItem_rcr* rb=rcr_createReadBinItem( T );
td = &rb->array[rb->index++];
rb->item.total=1;
}
void rcr_TAILWRITECASE(HashStructure *T, BinItem_rcr *val, BinItem_rcr *bintail, int key, SESEcommon * task, struct rcrRecord *rcrrec, int index) {
- ReadBinItem_rcr* rb=rcr_createReadBinItem();
+ ReadBinItem_rcr* rb=rcr_createReadBinItem( T );
TraverserData * td = &(rb->array[rb->index++]);
rb->item.total=1;
rb->item.status=NOTREADY;
// at this point have locked bin
BinItem_rcr *ptr=val;
+ BinItem_rcr *next;
int haveread=FALSE;
int i;
while (ptr!=NULL) {
+ next = ptr->next;
if (ISREADBIN(ptr->type)) {
if (ptr->status==NOTREADY) {
ReadBinItem_rcr* rptr=(ReadBinItem_rcr*)ptr;
haveread=TRUE;
} else if (ptr==val) {
val=val->next;
+ poolfreeinto( T->memPoolRead, ptr );
}
} else if (ptr->total==0) {
//skip past retired item
- if (ptr==val)
+ if (ptr==val) {
val=val->next;
+ poolfreeinto( T->memPoolWrite, ptr );
+ }
} else {
//write bin case
if (haveread)
ptr->status=READY;
if(((INTPTR)wptr->task)&PARENTBIN) {
val=val->next;
+ poolfreeinto( T->memPoolWrite, ptr );
} else
break;
}
}
- ptr=ptr->next;
+ ptr = next;
}
be->head=val; // release lock
}
#include "mlp_runtime.h"
//#include "WaitingQueue.h"
+#include "memPool.h"
#define bitvt unsigned long long
typedef struct Hashtable_rcr {
BinElement_rcr array[RNUMBINS];
// WaitingQueueBin * waitingQueue;
+
+ // use a different memory queue for each
+ // bin item type because the difference in
+ // size is very big
+ MemPool* memPoolWrite;
+ MemPool* memPoolRead;
} HashStructure;
//Todo this is a clone of REntry, remove data fields as necessary
HashStructure ** rcr_createMasterHashTableArray(int maxSize); //temporary
HashStructure* rcr_createHashtable(int sizeofWaitingQueue);
-WriteBinItem_rcr* rcr_createWriteBinItem();
-ReadBinItem_rcr* rcr_createReadBinItem();
+WriteBinItem_rcr* rcr_createWriteBinItem( HashStructure* htable );
+ReadBinItem_rcr* rcr_createReadBinItem( HashStructure* htable );
inline int rcr_generateKey(void * ptr);
//Method signatures are not in their final form since I have still not decided what is the optimum amount of data