| | |
| | | |
| | | static size_t hashcode(int key); |
| | | |
| | | static struct timespec TIMEOUT = {1, 0}; |
| | | |
| | | void hashtable_init(hashtable_t *hashtable ) |
| | | { |
| | | |
| | |
| | | /*printf("hashfun = %ld\n", code);*/ |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | void *hashtable_get(hashtable_t *hashtable, int key) { |
| | | struct timespec timeout = {1, 0}; |
| | | if (SemUtil::dec_timeout(hashtable->mutex, &timeout) != 0) { |
| | | |
| | | if (SemUtil::dec_timeout(hashtable->mutex, &TIMEOUT) != 0) { |
| | | SemUtil::inc(hashtable->mutex); |
| | | SemUtil::dec(hashtable->mutex); |
| | | } |
| | |
| | | int hashtable_alloc_key(hashtable_t *hashtable) { |
| | | int key = START_KEY; |
| | | |
| | | struct timespec timeout = {1, 0}; |
| | | if (SemUtil::dec_timeout(hashtable->wlock, &timeout) != 0) { |
| | | if (SemUtil::dec_timeout(hashtable->wlock, &TIMEOUT) != 0) { |
| | | SemUtil::inc(hashtable->wlock); |
| | | SemUtil::dec(hashtable->wlock); |
| | | } |