From 344e78d8d00fc76086b7078884ab2d82f9a6f973 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期一, 13 九月 2021 15:53:21 +0800
Subject: [PATCH] cgo -lshm_queue
---
src/shm/hashtable.h | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/shm/hashtable.h b/src/shm/hashtable.h
index 35b5892..7bb6eac 100755
--- a/src/shm/hashtable.h
+++ b/src/shm/hashtable.h
@@ -5,15 +5,22 @@
#include <functional>
#include <set>
-#define MAPSIZE 100
+#define MAPSIZE 4096
+
+// 鍒涘缓Queue鏁伴噺鐨勪笂闄�
+#define QUEUE_COUNT_LIMIT 300
typedef struct hashtable_t
{
struct tailq_header_t* array[MAPSIZE];
int mutex;
+ int queueCount;
+ int currentKey; // 褰撳墠鍒嗛厤鐨刱ey
// int wlock;
// int cond;
// size_t readcnt;
+
+
} hashtable_t;
typedef void (*hashtable_foreach_cb)(int key, void *value);
@@ -21,14 +28,16 @@
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_get_queue_count(hashtable_t *hashtable) ;
/**
* 閬嶅巻hash_table
* @demo
- * hashtable_foreach(&hashtable, [&](int key, void * value){
+ * hashtable_foreach(hashtable, [&](int key, void * value){
* printf("%d, %p\n", key, value);
* });
*
--
Gitblit v1.8.0