Added pthread support for llookup and mlookup hash
[IRC.git] / Robust / src / Runtime / DSTM / interface / llookup.h
1 #ifndef _LLOOKUP_H_
2 #define _LLOOKUP_H_
3
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <pthread.h>
7
8 #define LOADFACTOR 0.75
9 #define HASH_SIZE 100
10
11 typedef struct lhashlistnode {
12         unsigned int oid;
13         unsigned int mid;
14         struct lhashlistnode *next;
15 } lhashlistnode_t;
16
17 typedef struct lhashtable {
18         lhashlistnode_t *table; // points to beginning of hash table
19         unsigned int size;
20         unsigned int numelements;
21         float loadfactor;
22         pthread_mutex_t locktable;
23 } lhashtable_t;
24
25 unsigned int lhashCreate(unsigned int size, float loadfactor);// returns 0 for success and 0 for failure
26 unsigned int lhashFunction(unsigned int oid); // returns 0 for success and 0 for failure
27 unsigned int lhashInsert(unsigned int oid, unsigned int mid); // returns 0 for success and 0 for failure
28 unsigned int lhashSearch(unsigned int oid); //returns mid, 0 if not found
29 unsigned int lhashRemove(unsigned int oid); //returns 0 if not success
30 unsigned int lhashResize(unsigned int newsize);  // returns 0 for success and 0 for failure
31
32 #endif