| | |
| | | |
| | | |
| | | |
| | | static inline void _hashtable_foreach(hashtable_t *hashtable, std::function<void(int, void *)> cb) { |
| | | static inline void _hashtable_foreach(hashtable_t *hashtable, std::function<void(int, void *)> cb) { |
| | | tailq_entry_t *item; |
| | | for (int i = 0; i < MAPSIZE; i++) { |
| | | tailq_header_t *my_tailq_head = hashtable->array[i] ; |
| | |
| | | } |
| | | |
| | | |
| | | void hashtable_foreach(hashtable_t *hashtable, hashtable_foreach_cb cb) { |
| | | void hashtable_foreach(hashtable_t *hashtable, std::function<void(int, void *)> cb) { |
| | | SemUtil::dec(hashtable->mutex); |
| | | hashtable->readcnt++; |
| | | if (hashtable->readcnt == 1) { |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | std::set<int> * hashtable_keyset(hashtable_t *hashtable) { |
| | | std::set<int> *keyset = new std::set<int>; |
| | | tailq_entry_t *item; |
| | |
| | | while(_hashtable_get(hashtable, key) != NULL) { |
| | | key++; |
| | | } |
| | | |
| | | // 占用key |
| | | _hashtable_put(hashtable, key, (void *)1); |
| | | SemUtil::inc(hashtable->wlock); |
| | | return key; |
| | | } |
| | | |
| | | |