| | |
| | | #include <functional> |
| | | #include <set> |
| | | |
| | | #define MAPSIZE 100 |
| | | #define MAPSIZE 1024 |
| | | |
| | | typedef struct hashtable_t |
| | | { |
| | | struct tailq_header_t* array[MAPSIZE]; |
| | | int mutex; |
| | | int wlock; |
| | | int cond; |
| | | size_t readcnt; |
| | | // int wlock; |
| | | // int cond; |
| | | // size_t readcnt; |
| | | |
| | | } hashtable_t; |
| | | typedef void (*hashtable_foreach_cb)(int key, void *value); |
| | |
| | | void hashtable_init(hashtable_t *hashtable); |
| | | void hashtable_destroy(hashtable_t *hashtable); |
| | | void *hashtable_get(hashtable_t *hashtable, int key); |
| | | void hashtable_put(hashtable_t *hashtable, int key, void *value); |
| | | void hashtable_put(hashtable_t *hashtable, int key, void *value) ; |
| | | bool hashtable_check_put(hashtable_t *hashtable, int key, void *value, bool overwrite) ; |
| | | |
| | | void *hashtable_remove(hashtable_t *hashtable, int key); |
| | | void hashtable_removeall(hashtable_t *hashtable); |
| | | |
| | | int hashtable_lock(hashtable_t *hashtable); |
| | | int hashtable_unlock(hashtable_t *hashtable); |
| | | /** |
| | | * 遍历hash_table |
| | | * @demo |