Fix to the hashtable for misisng mod of hashsize

Addition of multiple reader/single writer locking mechanism
This commit is contained in:
Mark Riddoch
2013-06-24 13:09:11 +02:00
parent 69de408d8a
commit aeda47c69d
5 changed files with 156 additions and 8 deletions

View File

@ -30,6 +30,8 @@
*
* @endverbatim
*/
#include <spinlock.h>
#include <atomic.h>
/**
* The entries within a hashtable.
@ -58,6 +60,9 @@ typedef struct hashtable {
int (*cmpfn)(void *, void *); /**< The key comparison function */
HASHMEMORYFN copyfn; /**< Optional copy function */
HASHMEMORYFN freefn; /**< Optional free function */
SPINLOCK spin; /**< Internal spinlock for the hashtable */
int n_readers; /**< Number of clients reading the table */
int writelock; /**< The table is locked by a writer */
} HASHTABLE;
extern HASHTABLE *hashtable_alloc(int, int (*hashfn)(), int (*cmpfn)());