From acbf282b23b4cbdebca562d67132573de3902f94 Mon Sep 17 00:00:00 2001
From: Fu Juntang <StrongTiger_001@163.com>
Date: 星期五, 17 九月 2021 10:45:43 +0800
Subject: [PATCH] Merge branch 'master' of http://os.smartai.com:9091/valib/c_bhomebus
---
src/shm/shm_mm.h | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/src/shm/shm_mm.h b/src/shm/shm_mm.h
index db1bea9..0ca0d08 100644
--- a/src/shm/shm_mm.h
+++ b/src/shm/shm_mm.h
@@ -1,9 +1,14 @@
#ifndef __SHM_MM_H__
#define __SHM_MM_H__
+#include "usg_common.h"
+#include "shm_allocator.h"
+#include "key_def.h"
#define SHM_QUEUE_ST_OPENED 0
-
#define SHM_QUEUE_ST_CLOSED 1
+#define SHM_QUEUE_ST_RECYCLED 2
+
+#define SHM_QUEUE_ST_SET 50
struct shm_queue_status_t {
@@ -24,8 +29,20 @@
void shm_mm_free (void *ptr);
+
template <typename T>
-T* shm_mm_attach(int key) ;
+T* shm_mm_attach(int key) {
+ void *ptr;
+ // T* tptr;
+ hashtable_t *hashtable = mm_get_hashtable();
+ ptr = hashtable_get(hashtable, key);
+ if(ptr == NULL || ptr == (void *)1 ) {
+ ptr = mm_malloc(sizeof(T));
+ hashtable_put(hashtable, key, ptr);
+ new(ptr) T;
+ }
+ return (T*)ptr;
+}
void shm_mm_free_by_key(int key) ;
@@ -34,4 +51,6 @@
int shm_mm_alloc_key();
-#endif
\ No newline at end of file
+typedef std::map<SHMString, int, std::less<SHMString>, SHM_STL_Allocator<std::pair<const SHMString, int> > > ProcDataZone;
+
+#endif
--
Gitblit v1.8.0