From b5fe7f9a3bcc2f20d127f9081c1cf132091f6a57 Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期五, 27 十一月 2020 15:25:13 +0800 Subject: [PATCH] update --- src/queue/hashtable.c | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/queue/hashtable.c b/src/queue/hashtable.c index ed3fe34..03b64b6 100755 --- a/src/queue/hashtable.c +++ b/src/queue/hashtable.c @@ -23,6 +23,8 @@ static size_t hashcode(int key); +static struct timespec TIMEOUT = {1, 0}; + void hashtable_init(hashtable_t *hashtable ) { @@ -179,12 +181,9 @@ /*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); } @@ -317,8 +316,7 @@ 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); } -- Gitblit v1.8.0