zhangmeng
2021-02-22 e888eb3aa0ee76cdbb9a8193be40075857d1cf41
add shm start resycle
4个文件已修改
26 ■■■■■ 已修改文件
bhomebus.go 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libcbhomebus.c 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libcbhomebus.h 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libcbhomebus_func.h 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
bhomebus.go
@@ -169,6 +169,15 @@
    return nil
}
// ShmStartRecycle recycle
func ShmStartRecycle() error {
    if libbhomebus == nil {
        return errors.New("C BHomeBus Handle Is Nil")
    }
    C.wrap_fn_shm_start_recycle(libbhomebus)
    return nil
}
// ShmAllocKey alloc key
func ShmAllocKey() int {
    if libbhomebus == nil {
libcbhomebus.c
@@ -65,6 +65,14 @@
    return fn_shm_alloc_key();
}
int wrap_fn_shm_start_recycle(hbhomebus lib){
    if (!fn_shm_start_recycle){
        fn_shm_start_recycle = (tfn_shm_start_resycle)dlsym(lib, l_shm_start_recycle);
        check_with_ret(fn_shm_start_recycle, lib, -1);
    }
    return fn_shm_start_recycle();
}
void wrap_fn_shm_destroy(hbhomebus lib){
    if (!fn_shm_destroy){
        printf("shm destroy failed\n");
libcbhomebus.h
@@ -12,6 +12,7 @@
// shm manipulate
static tfn_shm_init                             fn_shm_init = NULL;
static tfn_shm_alloc_key                        fn_shm_alloc_key = NULL;
static tfn_shm_start_resycle                    fn_shm_start_recycle = NULL;
static tfn_shm_destroy                          fn_shm_destroy = NULL;
static tfn_shm_remove_keys                      fn_shm_remove_keys = NULL;
static tfn_shm_remove_keys_exclude              fn_shm_remove_keys_exclude = NULL;
@@ -63,6 +64,7 @@
// shm
const static char l_shm_init[] = "shm_mm_wrapper_init";
const static char l_shm_destroy[] = "shm_mm_wrapper_destroy";
const static char l_shm_start_recycle[] = "shm_mm_wrapper_start_resycle";
const static char l_shm_alloc_key[] = "shm_mm_wrapper_alloc_key";
const static char l_shm_remove_keys[] = "shm_mm_wrapper_remove_keys";
const static char l_shm_remove_keys_exclude[] = "shm_mm_wrapper_remove_keys_exclude";
@@ -119,6 +121,7 @@
// shm manipulate
void wrap_fn_shm_init(hbhomebus lib, int size);
int wrap_fn_shm_alloc_key(hbhomebus lib);
int wrap_fn_shm_start_recycle(hbhomebus lib);
void wrap_fn_shm_destroy(hbhomebus lib);
int wrap_fn_shm_remove_keys(hbhomebus lib, void *keys, int length);
int wrap_fn_shm_remove_keys_exclude(hbhomebus lib, void *keys, int length);
libcbhomebus_func.h
@@ -47,6 +47,12 @@
typedef int(*tfn_shm_alloc_key) ();
/**
 * @brief 回收标记为删除的队列
 * @return 错误码
 */
typedef int (*tfn_shm_start_resycle)() ;
/**
 * 批量删除key对应的共享队列,并在bus里删除该key的订阅
 */
typedef int(*tfn_shm_remove_keys) (int*, int);